473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Comparing SQL Server and User dates

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
4 2390
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
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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harlan Dorado | last post by:
Hi, I'm trying to write a function to compare a date posted from a text field in an asp-page to the date today. The idea is that the date entered in the form field cannot be in the past. This is...
2
by: Mike N. | last post by:
I am currently using a function to validate a form on the client side (see code below). At the end of the function, I would like it to also compare a startDate against an endDate to ensure that the...
5
by: jnikle | last post by:
I have two completely unrelated tables, one for reviews and another for pay periods. The reviews table has a review date in it, and the pay periods table is just a list of the beginnings of pay...
2
by: Duppypog | last post by:
I'm trying to compare a date stored in a database with today's date using an If statement, but it's not returning true. Example, value in database is 11/5/2003 with today being 11/6/2003. Can...
2
by: ameshkin | last post by:
Hi GUys, Im trying to compare two dates in MYSQL. But its not treating the dates as numbers, but as strings. I try using strtotime but that did not work. Basically, if the last comment is...
5
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one...
12
by: colincolehour | last post by:
I am new to Python and am working on my first program. I am trying to compare a date I found on a website to todays date. The problem I have is the website only shows 3 letter month name and the...
4
by: cheryl | last post by:
I am using the PHP.MYSQL and Apache server application in developing my website. I have problem in comparing dates. Website has room reservation, the user will check first the room availability. The...
2
by: dantebothermy | last post by:
Is there a simple way to subtract the time from a datetime field, so when I compare dates, I'm always comparing the dates at 12:00 am? I'd really prefer not to convert all my dates to strings. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.