Skip to main content

Different Date Formats in T-SQL and PL/SQL SQL Server

Here i have share different Date formats in T-SQL and PL/SQL you can use it to display your date according to your requirements .
Remember dates format should not be used in 'where' condition you must cast it as datetime (for T-SQL)

for example if you want to remove time part you can use  like this
SELECT CONVERT (VARCHAR,GETDATE(),101) it will show you only date
 but if you want to compare in 'where' condition you must cast it as datetime like this:

SELECT cast( CONVERT (VARCHAR,GETDATE(),101) as datetime)

Because without casting it will  act as varchar and in different scenarios like 'between'  , > <  it will not give you the correct result.

--Format 'MM/dd/yyyy'    2011-06-20 00:00:00.000
--select to_char(sysdate,'MM/dd/yyyy') from dual    --pl/sql

--Format 'yyyy.MM.dd' 2011-06-20 00:00:00.000
--select to_char(sysdate,'yyyy.MM.dd') from dual   --pl/sql

--Format 'dd/MM/yyyy'  20/06/2011

--select to_char(sysdate,'dd/MM/yyyy') from dual  --pl/sql

--Format 'dd.MM.yyyy' 20.06.2011
--select to_char(sysdate,'dd.MM.yyyy') from dual   --pl/sql

--Format 'dd-MM-yyyy' 20-06-2011
--select to_char(sysdate,'dd-MM-yyyy') from dual  --pl/sql

--Format 'dd MMM yyyy' 20 Jun 2011

--Format 'MMM dd,yyyy' Jun 20, 2011

--Format  'hh:mm:ss' 21:42:43
--select to_char(sysdate,'hh:mm:ss') from dual   --pl/sql
--Format 'MMM dd yyyy hh:mm:ss' Jun 20 2011  9:42:52:133PM

--Format 'MM-dd-yyyy' 06-20-2011
--select to_char(sysdate,'MM-dd-yyyy') from dual   --pl/sql

--Format 'yyyy/MM/dd' 2011/06/20
--select to_char(sysdate,'yyyy/MM/dd') from dual   --pl/sql

--Format 'yyyyMMdd' 20110620
--select to_char(sysdate,'yyyyMMdd') from dual  --pl/sql

--Format 'dd MMM yyyy hh:mm:ss:mss' 20 Jun 2011 21:43:33:343

--Format 'hh:mm:ss:ss'  21:43:50:203
--select to_char(sysdate,'hh:mm:ss:ss') from dual     --pl/sql


Popular posts from this blog

Add Image in Navigation Drawer Android Studio Template

I have to add Image in one of my project in slider Menu ,
I have used Android Studio Template Navigation Drawer  for material design .
For adding header on top of the list I have modified few lines in code: below are the simple steps:

Create an Android Studio project and select  Navigation Drawer Activity as shown below
Now your project structure is like this:

Now open activity_main.xml  and add LinearLayout and image view as shown below highlighted lines

< xmlns:android=""xmlns:tools="" android:id="@+id/drawer_layout"android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <FrameLayout android:id="@+id/container" android:layout_width="match_parent"
android:layout_height="match_parent" />


Using GIT with Android Studio on windows with terminal or toolbar

Today We are going to learn how we can create a git repository using android studio.
Android Studio Makes it very simple just follow the below steps and your project is on git :
First we setup our PC ::

Download git from :

install it.

for git repository online I am using Bitbucket  , bitbucket allow us to host private repository free you can also use github but your project should be public if you want to use it free.

Here I am going to use bitbucket:
Create repository
After creating repository  you will see screen like this

Now open AndroidStudio Create new project.
after creating the project clcik on VCS on menu strip  and enable git as shown below

Now your project git enabled ;
You can see terminal in andoid studio we can use it for git commands.
Now check terminal and write git status if it  give you below message :
'git' is not recognized as an internal or external command, operable program or batch file.
then you have to follow below steps …

Crystal Reports ToWords() and Propercase() function

I have to convert amount into words like 2150 to two thousand and fifty only .
for achieving this i have used towords() function in crystal report,

i have just create new formula

ToWords({abc.amount},0)+" Only"
 it returns me result but in lower case so i have converted into upperCase  like this
UpperCase(towords({abc.amount},0)) +" Only"
it returns me TWO THOUSAND AND FIFTY ONLY but i need First letter capital of every word
then i used
ProperCase(ToWord({abc.amount},0)+" Only"

ProperCase() give me following result

Two Thousand And Fifty Only

Hope it will help someone :)
HappyCoding :)