By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,534 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Comparing SQL Server and User dates

P: n/a
F
Hi

I have posted the question few days back about problem in inserting the
dates in SQL server and thankful to them who replied.
That was solved and this is a nice solution.
http://www.aspfaq.com/show.asp?id=2023

Now I am facing another problem.

I have to get data between two dates. That dates user has to provide and in
a specific format like dd/mm/yyyy if SQL server date format is same then no
problem but if SQL server format mm/dd/yyyy then I am getting error.

Please advise how to solve this problem.

Kind Regards


Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
CJM
Three obvious solutions are:

- To publish the format that you expect the dates to be given in, so the
user knows what is expected of them.
- Use some sort of calendar script so there can be no ambiguity
- Break the date in separate Day, Month and Year fields (with drowdowns
perhaps)

I use the first idea for most intranet apps, and the second for most web
apps.

Chris

"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
Hi

I have posted the question few days back about problem in inserting the
dates in SQL server and thankful to them who replied.
That was solved and this is a nice solution.
http://www.aspfaq.com/show.asp?id=2023

Now I am facing another problem.

I have to get data between two dates. That dates user has to provide and in a specific format like dd/mm/yyyy if SQL server date format is same then no problem but if SQL server format mm/dd/yyyy then I am getting error.

Please advise how to solve this problem.

Kind Regards


Jul 19 '05 #2

P: n/a
F
> - To publish the format that you expect the dates to be given in, so the
user knows what is expected of them
In this option problem is I am not sure about the system date it can be
dd/mm/yyyy or mm/dd/yyyy and when comparing it gives error.
- Use some sort of calendar script so there can be no ambiguity
I am already using calandar for input and this calander always provide
dates in dd/mm/yyyy what ever the system format and again if system format
is not dd/mm/yyyy
- Break the date in separate Day, Month and Year fields (with drowdowns
perhaps)
This solution is better but in my SQL Query I have to get date as YYYYMMDD
format so comapring will not be a problem. But Only comes when I am
adding/substarcting days from this date.

Any how thanks for your help.

Regards



"CJM" <cj*******@newsgroups.nospam> wrote in message
news:OM**************@tk2msftngp13.phx.gbl... Three obvious solutions are:

- To publish the format that you expect the dates to be given in, so the
user knows what is expected of them.
- Use some sort of calendar script so there can be no ambiguity
- Break the date in separate Day, Month and Year fields (with drowdowns
perhaps)

I use the first idea for most intranet apps, and the second for most web
apps.

Chris

"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
Hi

I have posted the question few days back about problem in inserting the
dates in SQL server and thankful to them who replied.
That was solved and this is a nice solution.
http://www.aspfaq.com/show.asp?id=2023

Now I am facing another problem.

I have to get data between two dates. That dates user has to provide and

in
a specific format like dd/mm/yyyy if SQL server date format is same then

no
problem but if SQL server format mm/dd/yyyy then I am getting error.

Please advise how to solve this problem.

Kind Regards



Jul 19 '05 #3

P: n/a
> In this option problem is I am not sure about the system date it can be
dd/mm/yyyy or mm/dd/yyyy and when comparing it gives error.
I don't know what you mean. Since you can control input by not letting a
user type a date in (pick from a dropdown or a calendar control), and since
you can control output by formatting the date yourself, I don't know where
the problem would come in.
I am already using calandar for input and this calander always provide
dates in dd/mm/yyyy


If you can't specify the format and can't fix it, use a different calendar.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #4

P: n/a
Take the value from your calendar (which you say is always dd/mm/yyyy) and
reformat it to yyyy-mm-dd before converting from a string to a date. That
way it will not matter what the server system date is.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
- To publish the format that you expect the dates to be given in, so the
user knows what is expected of them
In this option problem is I am not sure about the system date it can be
dd/mm/yyyy or mm/dd/yyyy and when comparing it gives error.
- Use some sort of calendar script so there can be no ambiguity


I am already using calandar for input and this calander always provide
dates in dd/mm/yyyy what ever the system format and again if system format
is not dd/mm/yyyy
- Break the date in separate Day, Month and Year fields (with drowdowns
perhaps)


This solution is better but in my SQL Query I have to get date as

YYYYMMDD format so comapring will not be a problem. But Only comes when I am
adding/substarcting days from this date.

Any how thanks for your help.

Regards



"CJM" <cj*******@newsgroups.nospam> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
Three obvious solutions are:

- To publish the format that you expect the dates to be given in, so the
user knows what is expected of them.
- Use some sort of calendar script so there can be no ambiguity
- Break the date in separate Day, Month and Year fields (with drowdowns
perhaps)

I use the first idea for most intranet apps, and the second for most web
apps.

Chris

"F@yy@Z" <fa**********@mvwebmaker.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
Hi

I have posted the question few days back about problem in inserting the dates in SQL server and thankful to them who replied.
That was solved and this is a nice solution.
http://www.aspfaq.com/show.asp?id=2023

Now I am facing another problem.

I have to get data between two dates. That dates user has to provide
and in
a specific format like dd/mm/yyyy if SQL server date format is same
then no
problem but if SQL server format mm/dd/yyyy then I am getting error.

Please advise how to solve this problem.

Kind Regards




Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.