Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !
A.I am using Date Format (dd/MM/yyyy) so store in DataBase in String Format.Because DateFormat of Database is (MM/dd/yyyy),can I change into (dd/MM/yyyy).
B.I am using GetDate() in SQL query, it require DateTime format.So how can I use it for string format of Date stored in Database.

Code is : In this Code FM_BankAC_Entry.Date is DateTime Format.I Require similar quiry for String Format.
SQL
SELECT     dbo.FM_BankAC_Entry.TransCode,dbo.FM_BankAC_Entry.TDate, dbo.FM_BankAC_Entry.TDetails, dbo.FM_BankAC_Entry.ChequeNo, dbo.FM_BankAC_Entry.AmtWithdr,FM_BankAC_Entry.AmtDep

FROM  FM_BankAC_Entry
where  FM_BankAC_Entry.Date between GETDATE()- @date1 and GETDATE()- @date2
        order by FM_BankAC_Entry.Date desc
Posted

First of all this is not a SQL forum and you should move this to the proper place for more answers and faster responses.

For any sql date functions, the date has to be in the proper format (MM/dd/yyyy) format. You should not store the date in string format in sql if you want to do date time comparison. Though by type casting you can convert a string value into a datetime one but here the date format is wrong. However, you can use the following expression:

SELECT CONVERT(datetime, @date1 , 103)
 
Share this answer
 
Comments
LebneizTech 18-Aug-10 6:23am    
Reason for my vote of 4
Got Tips
What do you mean?
If your field is in DateTime format then database does not store it in format. It just a date. It only shows depending on your regional setting.

But if you want to convert the date into any Varchar format then try Convert in SQL server. or take a look at System.Globalization.CultureInfo in VB.
 
Share this answer
 
Thanks

I got the Tips for this Question.
 
Share this answer
 

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