473,383 Members | 1,978 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,383 software developers and data experts.

Having problems with dates

489 256MB
I don't know why I'm having so much problem with this date. I have a database that we are adding the birthdate to. I've setup the field in the master file and have a update screen that the user select the person from a drop down menu. When I try and do an update statement with the birthdate = #" & Birthdate & "# if there is a birthdate entered it works fine. If they call up a person and don't enter a birthdate I get an error, it doesn't like a null date but it's ok to have a null date. Where am I going wrong why can't I have a null date?
Thanks again for all your help.
Jan 25 '10 #1
8 1427
CD Tom
489 256MB
PS: the error I get is Run-Time error 3075
syntax error in date in query expression '#' when I look at it it's Null
Jan 25 '10 #2
ajalwaysus
266 Expert 100+
You cannot pass a null to a date, so you may need to use an if statment to build your query.

Example:

Expand|Select|Wrap|Line Numbers
  1. If IsNull(BirthDate) then
  2.      strSQL = "SELECT *" & _
  3.      " FROM Table1" & _
  4.      " WHERE Person = 'AJ'"
  5. Else 
  6.      strSQL = "SELECT *" & _
  7.      " FROM Table1" & _
  8.      " WHERE Person = 'AJ'"
  9.      " AND birthdate = #" & Birthdate & "#"
  10. Endif
-AJ
Jan 25 '10 #3
NeoPa
32,556 Expert Mod 16PB
In SQL you can set a field to Null, but not an empty date literal.

It's the difference between :
Expand|Select|Wrap|Line Numbers
  1. Set MyDate = #5/31/2010#
  2. Set MyDate = ##
  3. Set MyDate = Null
The first is valid. The third is valid (for Date fields which allow Nulls). The second is not.
Jan 26 '10 #4
CD Tom
489 256MB
How do you set a date field to allow nulls?
Jan 26 '10 #5
NeoPa
32,556 Expert Mod 16PB
As with any field, you set the Required property to No in the field design.
Jan 26 '10 #6
CD Tom
489 256MB
It is already set to No in the required field, I checked that first. But when Iset the vbirthdate = null and try to update the record with an sql update statement and use Birthdate = #" & vbirthdate & "# I get the error.
syntax error in date in query expression '#'
Jan 27 '10 #7
NeoPa
32,556 Expert Mod 16PB
I've already covered that point in post #4 Tom. Check it again.
Jan 27 '10 #8
TheSmileyCoder
2,322 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. birthdate = nz(Birthdate,#" & Birthdate & "#,null)
Jan 29 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alistair | last post by:
ok..here's the thing.. I have a calendar app that is really starting to bug me.. www.corruption.co.uk/events/calendar.asp I have response.written the SQL command and the results so you can...
5
by: Jonathan Crawford | last post by:
Hi I am niew to pho and am having trouble with dates. I can format a date ok so $today=date('d M Y' ) gives me 2 Nov 2005 $dateval is a mysql date
5
by: Jim Fox | last post by:
I have a report that I created that has no data, just boxes, lines and one date field not tied to anything. Basically this report will just print pages according to the dates you entered. Then...
1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
9
by: Neil | last post by:
I have been coding with ASP for some time now. I am using an ACCESS database. I am in the UK and wish to use DD/MM/YYYY format for dates. I have had no end of problems and possible solutions to...
1
by: tangokilo | last post by:
Hi, I am at a loss! So please excuse me as a true novice at this....!!! How can I compare dates in a windows form (not web form) using VB.NET and SQL 2000? For example, one date is blank...
2
by: Middletree | last post by:
This could be an Excel thing, but I am not ruling out my ASP code. Using ASP 3.0, I give the user the ability to create a spreadsheet with a click. In the resulting spreadsheet, I have 2 columns...
11
by: garyusenet | last post by:
I have 'cli via c# on order', and in the mean time am reading 'Pro C# 2005 and the .NET platform' (Andrew Troelson). I'm just reading about the 'five types defined in the CTS'. Specifically Struct....
3
by: Brian Simmons | last post by:
Hi all, I'm just having one of those days where seemingly easy problems are giving me a devil of a time. Here's the scenario: Company's fiscal year runs from 10/1/YY -9/30/(YY+1), i.e....
2
by: ncsthbell | last post by:
I am having problems getting the end date to calculate correctly. I start with Quarter '03/02', (YY/QTR), for this it means it is for the 2nd qtr of 2003. My goal is to get the begin & end dates...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.