Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Datetime field

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2013-03-07 : 05:42:04
Hi

I have datetime field . Regional Settings is MM/dd/yyyy. In which format date will be stored in Database

Thanks

rjhe22
Constraint Violating Yak Guru

283 Posts

Posted - 2013-03-07 : 05:53:57
probably yyyy/mm/dd all mine do
Go to Top of Page

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2013-03-07 : 06:07:07
Hi

When i insert record i gave written this
Format(DTPicker3.Value, "MM/dd/yyyy") . On what basis date is stored in Database.

Thanks
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-03-07 : 06:16:55
In which database are you going to store? .. If SQL server then check the default format by executing

SELECT getdate()

You'll find the format in which SQL server stored date datatype value in a field.

Cheers
MIK
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-07 : 06:22:05
quote:
Originally posted by sunny_10

Hi

When i insert record i gave written this
Format(DTPicker3.Value, "MM/dd/yyyy") . On what basis date is stored in Database.

Thanks


dates are stored in sql server internally as integer values. when you select datetime field the values will be shown in iso format yyyy-mm-dd hh:mi:ss
You can apply CONVERT() function to get it in format you want by making it varchar and specifying a style value which corresponds to format. This can also be done in front end applications using format functions available there.

See below links for more info

http://visakhm.blogspot.in/2012/07/generate-datetime-values-from-integers.html

http://visakhm.blogspot.in/2011/12/why-iso-format-is-recommended-while.html

http://msdn.microsoft.com/en-IN/library/ms187928.aspx



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -