October 6th, 2007, 05:23 AM
I am using SQL Server 2000 with my web site hosting.
I have a field in database which is smalldatetime.
When the form tries to insert date to database, it tries to enter MM/DD/YYYY.
But what I need is to store it as DD/MM/YYYY.
A wise man remembers his friends at all times; a fool, only when he has need of them
October 6th, 2007, 05:49 AM
DS, i dont think that u can change the way SQL Server stores the date.
October 6th, 2007, 05:56 AM
I show the dates to the customers using a calendar in the form, M
When they select the date, e.g. 01/10/2007, the calendar handles the right format.
Using datepart function I am able to replace 01/10/2007 to 10/01/2007.
after getting the format 10/01/2007, it stores as 01/10/2007.
Am I doing something wrong M?
October 6th, 2007, 06:05 AM
y do u want to change the format while saving in db?
it'll save in MM/DD/YYYY format only.
U can change the format when u show it on page.
October 6th, 2007, 06:42 AM
M, I am able to change how it looks on the page.
eg. rr_txtOrderDate is the date from user selection which is dd/mm/yyyy
Lets say 25/10/2007
Then I convert the using Datepart
Then I get 10/25/2007. It is supposed to save into database as it is.(at least I have known like that!)
intDate=DatePart("m", rr_txtOrderDate)& "/" & DatePart("d", rr_txtOrderDate)& "/" & DatePart("yyyy", rr_txtOrderDate)
But while inserting, it again converts the date into 25/10/2007.
I am not sure whether it is safe to manipulate the field in that way or should it be another efficient way?
What would you say M?
October 6th, 2007, 07:52 AM
DS, now u r confusing me!
first u said that its inserting in MM/DD/YYYY format........ now u saying that its converting to 25/10/2007.
May b its time that some expert jump in here
October 6th, 2007, 07:58 AM
It now works M right now but as I said I am not sure whether it is the right approach only?
October 9th, 2007, 05:30 AM
(c) BOL, datetime and smalldatetime
You may use
SET DATEFORMAT DMY