473,800 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strange behaviour with date in SQL

Hi,

The Access table "dayoff" contains following dates:
8/4/2004 till 8/14/2004 (in dd-mm-yy format).
'dat1' and 'dat2' contains dates coming from two combo-boxs.
When 'dat1' contains "8/4/2004" and 'dat2' contains "8/9/2004", no problem:
there are deleted.
When 'dat1' contains "8/10/2004" and 'dat2' contains "8/14/2004", no problem
either: there are deleted
But when 'dat1' contains "8/4/2004" and 'dat2' contains "8/14/2004", only
8/4/2004 and 8/14/2004 are deleted.
So it remains 8/5/2004 till 8/9/2004 and then when 'dat1' contains
"8/4/2004" and 'dat2' contains "8/13/2004", nothing is deleted.

Where is my fault? (i tried with 'Between' and with >= ... <=)
Thanks
bjorn

<%
dat1=cdate(requ est.form("em3") )
dat2=cdate(requ est.form("em4") )

response.write( dat1 & " " & dat2) 'this gives e.g. 8/4/2004 or
8/14/2004 ...

set objdc = Server.CreateOb ject("ADODB.Con nection")
objdc.Open("pro vider=Microsoft .Jet.OLEDB.4.0; Data Source
=d:\access\newr es.mdb")
'strsql="delete from verlof where cdate(datum) >= '" & dat1 & "' and
cdate(datum)<= '" & dat2 & "';"
strsql="delete from verlof where cdate(datum) between '" & dat1 & "' and '"
& dat2 & "';"
objdc.execute strsql, , adcmdtext and adcmdexecutenor ecords
%>
Jul 19 '05 #1
13 1491
Bjorn wrote:
Hi,

The Access table "dayoff" contains following dates:
8/4/2004 till 8/14/2004 (in dd-mm-yy format).


What is the data type of those fields? If they are Date/Time fields, then
they will not be stored with any format. If they are Text fields, then they
will not be treated as dates.

Here are a few links to help you out with dates:

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
Thanks for replying.

The field in Access is Date/Time (i change the field format property to
dd-mm-yy).
When i add the conversion function:

Function pd(n, totalDigits)
if totalDigits > len(n) then
pd = String(totalDig its-len(n),"0") & n
else
pd = n
end if
End Function
dat1=pd(DAY(dat 1),2) & "-" & _
pd(MONTH(dat1), 2) & "-" & _
pd(RIGHT(YEAR(d at1),2),2)
dat2=pd(DAY(dat 2),2) & "-" & _
pd(MONTH(dat2), 2) & "-" & _
pd(RIGHT(YEAR(d at2),2),2)

it's worst: nothing is deleted in any case ..

??
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:OD******** ******@tk2msftn gp13.phx.gbl...
Bjorn wrote:
Hi,

The Access table "dayoff" contains following dates:
8/4/2004 till 8/14/2004 (in dd-mm-yy format).
What is the data type of those fields? If they are Date/Time fields, then
they will not be stored with any format. If they are Text fields, then

they will not be treated as dates.

Here are a few links to help you out with dates:

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #3
Correction:

the field is Date/Field type, but the regional options of Windows are set on
dd-mm-yy (i didn't change the field property)
Jul 19 '05 #4
> The field in Access is Date/Time (i change the field format property to
dd-mm-yy).


AAAARRGH!!! WHY???

Use YYYY-MM-DD! This is the only format that is going to prevent you from
getting d/m/y and m/d/y mixed up. Please do yourself a favor and do this
right! If you want to present d/m/y to users, do that at presentation.
Don't screw up the storage aspect.

A
Jul 19 '05 #5
Aaron [SQL Server MVP] wrote:
The field in Access is Date/Time (i change the field format property
to dd-mm-yy).


AAAARRGH!!! WHY???

Use YYYY-MM-DD! This is the only format that is going to prevent you
from getting d/m/y and m/d/y mixed up. Please do yourself a favor
and do this right! If you want to present d/m/y to users, do that at
presentation. Don't screw up the storage aspect.

A


:-)
The field format property only affects display and entry.:-)
Dates are stored as Doubles, regardless of the format property setting.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #6
> The field format property only affects display and entry.:-)

I know that, but why have an ambiguous entry format? It makes no sense. If
I enter 08-06-04, it gets stored as June 8th, which isn't what everyone will
expect.

A
Jul 19 '05 #7
Thanks, but i posted a correction before you answered me (below) ...

the field is Date/Field type, but the regional options of Windows are set on
dd-mm-yy (i didn't change the field property).

I have changed the field property to YYYY-MM-DD but nothing changed.

In ASP, the SQL command gets dates in format 8/3/2004.
In my Access table, the format is dd-mm-yyy due to regional settings i can't
change.

The problem is: which format must 'dat1' and 'dat2' have in order to
understand each other?
I tried to convert the ASP dates with:
Function pd(n, totalDigits)
if totalDigits > len(n) then
pd = String(totalDig its-len(n),"0") & n
else
pd = n
end if
End Function
dat1=pd(DAY(dat 1),2) & "-" & _
pd(MONTH(dat1), 2) & "-" & _
pd(RIGHT(YEAR(d at1),2),2)
dat2=pd(DAY(dat 2),2) & "-" & _
pd(MONTH(dat2), 2) & "-" & _
pd(RIGHT(YEAR(d at2),2),2)

but it's worst: nothing is deleted in any cas

What can i do more?


Jul 19 '05 #8
Aaron [SQL Server MVP] wrote:
The field format property only affects display and entry.:-)


I know that, but why have an ambiguous entry format? It makes no
sense. If I enter 08-06-04, it gets stored as June 8th, which isn't
what everyone will expect.

A


OK, to expand on the point (for Bjorn's benefit), the Format property only
affects display and entry IN ACCESS. It has no affect on data entered from
or displayed in any external applications (such as ASP). IOW, it's totally
irrelevant to his ASP problems.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #9
Bjorn, you're missing the point. Your date in ASP, before sending it to
Access, should be YYYY-MM-DD. Your function makes it dd-mm-yy. Stop
worrying about the format in Access, that part is irrelevant. Get your
dates that you are passing TO access into an unambiguous format.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Bjorn" <no****@rt.sw > wrote in message
news:uB******** ******@TK2MSFTN GP11.phx.gbl...
Thanks, but i posted a correction before you answered me (below) ...

the field is Date/Field type, but the regional options of Windows are set on dd-mm-yy (i didn't change the field property).

I have changed the field property to YYYY-MM-DD but nothing changed.

In ASP, the SQL command gets dates in format 8/3/2004.
In my Access table, the format is dd-mm-yyy due to regional settings i can't change.

The problem is: which format must 'dat1' and 'dat2' have in order to
understand each other?
I tried to convert the ASP dates with:
Function pd(n, totalDigits)
if totalDigits > len(n) then
pd = String(totalDig its-len(n),"0") & n
else
pd = n
end if
End Function
dat1=pd(DAY(dat 1),2) & "-" & _
pd(MONTH(dat1), 2) & "-" & _
pd(RIGHT(YEAR(d at1),2),2)
dat2=pd(DAY(dat 2),2) & "-" & _
pd(MONTH(dat2), 2) & "-" & _
pd(RIGHT(YEAR(d at2),2),2)

but it's worst: nothing is deleted in any cas

What can i do more?


Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1437
by: Darren | last post by:
I used the following code on a server; <% ReturnDateTime 1033, "English (US)" ReturnDateTime 2057, "English (UK)" ReturnDateTime 3081, "English (Australia)" ReturnDateTime 1031, "German" Sub ReturnDateTime(locale, description) Session.LCID = locale
0
2705
by: Ethel Aardvark | last post by:
I am running a 9.0.1 database on a W2K server and have come across some strange behaviour with a SQL query. I have a query which runs in a PL/SQL cursor which has several PL/SQL variables used to switch on and off certain rules. One idea I had was to have two queries UNIONed together with a simple switch selecting which half was to operate (I know it sounds like there are probably better ways of doing this but I have my reasons). To cut...
2
1977
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from std::exception. We have a base class which all processes derive from which is always instantiated in main surrounded by a try/catch(std::exception) which catches all exceptions that have not be handled at a higher level. The catch block cleans up and...
3
4877
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP Developer (SP3 for Office, SP1 for developer, JET40SP8) on Windows XP Home Edition (SP1). The same behaviour occurs on Windows 98 too.
6
2939
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd have better luck here. So here goes! My program ignores any command line arguments, or at least it's supposed to. However, when I pass any command line arguments to the program, the behaviour of one of the functions changes mysteriously. I have...
8
3222
by: FBM | last post by:
Hi there, I am puzzled with the behavior of my code.. I am working on a networking stuff, and debugging with eclipse (GNU gdb 6.6-debian).. The problem I am experiencing is the following: Whenever I declare the sockaddr_in structure inside the main, the debugger crashes at line X*, not being able to access argv parameters (see code below). It is very strange.. by only being there, sockaddr_in does not allow me to question argc...
8
5322
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples. (Sorry, long email) The first two examples are behaving normal, the thirth is strange....... I wrote the following flabbergasting code: #-------------------------------------------------------------
20
2246
by: Pilcrow | last post by:
This behavior seems very strange to me, but I imagine that someone will be able to 'explain' it in terms of the famous C standard. -------------------- code ----------------------------------- #include <stdio.h> int main (void) { char xx="abcd"; char * p1 = xx;
0
9697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9555
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10291
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9100
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7589
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.