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
 conversin from string dd/mm/yyyy format

Author  Topic 

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 05:41:22
hi,
i have a problem.
i m inserting data in "dd/mm/yyyy" string format and i want to ocnvert in "dd mon yyyy" format.
for eg-- i m entering 30/11/2007" and i wnat in this format "30 Nov 2007"

if any body knows please help me.
thanx...

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 05:47:02
plssssany body....provide me soln.....
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-09-12 : 05:47:53
look up convert...
but you don't really have to worry about how the date is stored, you just only need to know how your sql server stores it so you can format it any way you like when retrieving

--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-12 : 05:48:59
1 Always use proper DATETIME datatype to store dates
2 When adding dates express them in YYYYMMDD format
2 Let your front end do formation

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 05:50:01

i have one soln like....
select CONVERT(varchar, CONVERT(datetime, '30/11/2006'), 106)
but i want ot give input as 11/30/2006.....
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-09-12 : 05:55:00
if you pass that value in a datetime variable
does it accept the date value?

are you worried that the date is misinterpreted?

store the value and retrieve it so you can verify

the key is test test test... no matter what others say,test test test
quote:
Originally posted by roop


i have one soln like....
select CONVERT(varchar, CONVERT(datetime, '30/11/2006'), 106)
but i want ot give input as 11/30/2006.....



--------------------
keeping it simple...
Go to Top of Page

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 06:04:32
actually there is some boundations thats why i m giving in dd/mm/yyyy format...so if any one has something pls tell me....
Go to Top of Page

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 06:13:29
nobody can tell?.....pls
Go to Top of Page

roop
Starting Member

9 Posts

Posted - 2007-09-12 : 07:58:00
if any body can saolve my problem....? my problem is that
i m inserting data in "dd/mm/yyyy" string format and i want to ocnvert in "dd mon yyyy" format.
for eg-- i m entering 30/11/2007" and i wnat in this format "30 Nov 2007"
pls...any one.........
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2007-09-12 : 08:03:36
Maybe this will clarify things for you about how datetime is stored. It's up to you when you display the data to use the convert function to display it in the proper format. It's not stored as a string unless you store a datetime as a string in a char type column.

http://www.sql-server-performance.com/articles/dev/datetime_datatype_p1.aspx

PS: If anyone is interested in a sql position in Connecticut with excellent pay send me your resume at ValterBorges@msn.com
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-09-12 : 08:37:09
quote:
Originally posted by roop

if any body can saolve my problem....? my problem is that
i m inserting data in "dd/mm/yyyy" string format and i want to ocnvert in "dd mon yyyy" format.
for eg-- i m entering 30/11/2007" and i wnat in this format "30 Nov 2007"
pls...any one.........



DO NOT WORRY ABOUT FORMATTING in sql server. Where are you ultimately displaying these dates? In a report, on a web page, in Excel, in an application? THAT is where you do all formatting. Just return the date in SQL, and let your front end handle making it look pretty. That's the easiest and most correct way to handle this.

See: http://weblogs.sqlteam.com/jeffs/archive/2007/04/13/60175.aspx

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-12 : 08:40:45
Handling dates seem to be a big problem to all newbies

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-09-12 : 08:52:49
It's amazing, isn't it? How much time and effort they spend doing something that they simply don't need to.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -