Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have a datet comming from some website like this

"05:41:33 Apr 23, 2012 PDT"
i want to save it into my database which has a datetime field .

so my question is how can i save this dateformat into my database.
Posted
Comments
Rahul Rajat Singh 24-Apr-12 8:12am    
I think if you pass your DateTime variable as is and the SqlServer will take care of it. Have you tried that?

Have a look at DateTime.ParseExact[^]. If you pass the format string then you can recreate the DateTime. Note that you are relying on the website in question not changing its formatting, but that is inevitable.
 
Share this answer
 
Hi,

U can use Varchar() Datatype in database for saving it even. And if you want to do operation on that later convert it to specific format as you like.
 
Share this answer
 
Comments
phil.o 24-Apr-12 8:01am    
Very bad idea to store dates as string in a database.
How would you compare dates in your SQL scripts then ?
Gurbax Singh 24-Apr-12 8:33am    
@SDAP_INDIA ---> are you kidding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900