473,785 Members | 2,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Format(Date) in SQL statement

Hello

I am having some problem comparing dates with the SQL statement below
MySQL = "SELECT Format(Date, 'yyyy/mmmm/dd') as [Expr1] FROM TblDates WHERE
_
Format(Date, 'yyyy/mmmm/dd') = #2006/April/18#"

Even though the date 2006/April/18 is in TblDates, it is never found by the
above SQL statement

Anyone know why?
Thanks

G Gerard
Apr 29 '06 #1
1 6539
G Gerard wrote:
Hello

I am having some problem comparing dates with the SQL statement below
MySQL = "SELECT Format(Date, 'yyyy/mmmm/dd') as [Expr1] FROM TblDates WHERE
_
Format(Date, 'yyyy/mmmm/dd') = #2006/April/18#"

Even though the date 2006/April/18 is in TblDates, it is never found by the
above SQL statement

Anyone know why?


If the field in your table is named "Date" then that's probably the problem. "Date" is a
reserved word and should never be used as a field name. You might get this to work by
enclosing the field name in brackets but using "Date" as a field name is a no-no.

And you don't need to use format in the WHERE clause; that's just going to slow you down.

MySQL = "SELECT Format([Date], 'yyyy/mmmm/dd') as yourDateName FROM TblDates" & _
" WHERE [Date] = #4/18/2006#;"

but it would be better as:

MySQL = "SELECT Format([myDate], 'yyyy/mmmm/dd') as yourDateName FROM TblDates" & _
" WHERE myDate = #4/18/2006#;"
--
'---------------
'John Mishefske
'---------------
Apr 29 '06 #2

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

Similar topics

1
3901
by: praba kar | last post by:
Dear All, In Php we can print RFC 2822 formatted date by date('r') with parameter r. Then it will print the below format date. "Thu, 7 Apr 2005 01:46:36 -0300". I want to print same RFC 2822 format in python. Is it possible in python? . If possible kindly mention the function related to print RFC format date
0
3113
by: lsy | last post by:
i wonder how can i order my statement interm of "ORDER BY FORMAT(Date, 'mmmm')" with using this it will order by alphabethical but i want it order by month... i had try "ORDER BY FORMAT(Date, 'mm')" but due to at the begining i have "SELECT FORMAT(Date, 'mmmm')FROM TABLE" my actual statement will look like this "SELECT FORMAT(Date, 'mmmm')AS DateMonth, COUNT(x) AS CounterX FROM Table WHERE FORMAT(Date, 'mmmm') BETWEEN 'January' AND 'August'...
1
5513
by: Keith Chadwick | last post by:
Been trying to use the ms:format-date() in one of my transformations. I have all of the necessary declarations in my xml as in <?xml version="1.0" ?> <data xml:space="default" xmlns:dt="urn:schemas-microsoft-com:datatypes"> myxml... </data>
1
580
by: '[] WiRaN | last post by:
one know format date in c#???? or validate?
1
1750
by: Kerri | last post by:
Hi, I am new to .NET. I have a server side text box on an ASPX Page. I want to format the date when the user tabs out / double clicks teh textbox or presses carriage retutrn. What event do I do this on..lost focus?
4
1638
by: Wayne Wengert | last post by:
I have an aspx page in which I retrieve data from an SQL Server. At one point I am retrieving a smalldatetime field and I want to display only "mm/dd/yy" but the default seems to be to add the time. The code to retrieve that date field is: <%#Container.DataItem("LastUpdated")%> I tried adding ".ToString("d")" but it doesn't recognize that as a formatting function. How can I format that returned value as mm/dd/yyyy?
2
79089
by: fniles | last post by:
How do you do Format(Date, "mmddyy") in VB.NET ? Thank you
8
5408
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
5
4221
mgpsivan
by: mgpsivan | last post by:
Hi, i have form in Asp.net(2003) in that i've to change the format of the date by the following statement Format(Date.Today, "dd/mm/yyyy") but when i give this code the month part displays as 00 i.e i get the output as the folowing for eg: "18/00/2007" can any one help me in changing the format... Thanks in Advance..... Sivan.G.....
0
9645
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
10327
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10092
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
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
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...
0
5381
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
4053
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
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.