Convert GetDate() to (DD/MM/YYYY) format

Posted on 2004-05-02
Last Modified: 2011-08-18
I am trying to run a conditional SQL statement to append info from one table to another where the Date in the DateField is >Todays but <Today+7.

I am using getdate() but i keep getting this error:

Undefined function 'getdate' in expression.
/DIGFootball/Admin/FriDiv3/update2.asp, line 143

[Line 142 =] sql6 = "Insert Into tblWeeklyFixtures_Div3 Select * From tblAllFixtures_div3 Where GameDate between getdate() and getdate()+7"
[Line 143 =] conn.execute(sql6)

I take it this error occurs because i need to convert the date format of Getdate() to (dd/mm/yyyy) but i dont know how to do this.  does anyone know how to do this and where i would need to put it?

Thanks for taking the time to read this
Question by:Pietro_P
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 10971224
Try this:

[Line 142 =] sql6 = "Insert Into tblWeeklyFixtures_Div3 Select * From tblAllFixtures_div3 Where GameDate between convert(DateTime,convert(varchar(11),getdate()))) and dateadd(day,+7 ,convert(DateTime,convert(varchar(11),getdate())))"

Author Comment

ID: 10971257
Thanks for the reply.

I tried it but i got this error

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Undefined function 'convert' in expression.

I just cant seem to please this god damn ASP!!!!!!!!
LVL 12

Accepted Solution

rcmb earned 20 total points
ID: 10971317
Two things to try:

Instead of getdate try Date() AND Date()+7

Or if your are doing this in ASP why not store the values in a variable and just call the variable
CurrDate = Date
NextWeekDate = Date +7
Where GameDate between #" & CurrDate & "# and #" & NextWeekDate & "#


Expert Comment

ID: 10971332
I was just about to suggest your second method RCMB.  Access does not support convert.

Expert Comment

ID: 10971677
Try the following...

sql6 = "INSERT INTO tblWeeklyFixtures_Div3 " &_
          "SELECT * " &_
          "FROM tblAllFixtures_div3 " &_
          "WHERE DATEDIFF('d','" & Date() & "',GameDate) >= 0  AND " &_
          "DATEDIFF('d','" & DATEADD("d",7,Date()) & "',GameDate) <= 0"

Doing the following test...

<%@ Language=VBScript %>
Dim sDate(4)

sDate(0) = "01/05/2002"
sDate(1) = "01/06/2004"
sDate(2) = "02/05/2004"
sDate(3) = "01/09/2004"
sDate(4) = "07/05/2004"

For iLp = 0 to UBOund(sDate)
      If DATEDIFF("d",Date(),sDate(iLp)) >= 0 and DATEDIFF("d",DATEADD("d",7,Date()),sDate(iLp)) <= 0 then
            Response.Write sDate(iLp) & "<br>"
      End If



Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question