I am using the DatePart funtion in a query to extract the day, month
and year in separate fields in a query. The function works fine but I
am only getting a number for the month even if the field type is a long
date and the month is stored in the table. I tried the following to try
and get the name of the month to work.
DateTest: Format(DatePart ("m",[DateAffirmed]),"mmmm")
The DateAffirmed field had a date stored of 16/03/2006.
the result gave me January even though the month is number 3. I then
tried the following to test the format
MarchDate: Format(3,"mmmm" )
This also returned January and when I test all the numbers from 1 - 12
the only one that didn't come out as January was number 1 which came
out as December.
Any ideas? 2 6786
Second part first:
0 is coerced to Dec 30 1899
1-> Dec 31 1899
2-> Jan 1 1900
etc
First part follows.
DatePart("m", Date) -> 3 -> Jan 2 1900
so you are asking for
Debug.Print Format(#1/3/1900#, "mmmm")
(in mm/dd/yyyy notation)
which is January
Possibly
Format(Date, "mmmm")
without extracting the month number first will work for you.
troddy wrote: I am using the DatePart funtion in a query to extract the day, month and year in separate fields in a query. The function works fine but I am only getting a number for the month even if the field type is a long date and the month is stored in the table. I tried the following to try and get the name of the month to work.
DateTest: Format(DatePart ("m",[DateAffirmed]),"mmmm")
The DateAffirmed field had a date stored of 16/03/2006.
the result gave me January even though the month is number 3. I then tried the following to test the format
MarchDate: Format(3,"mmmm" )
This also returned January and when I test all the numbers from 1 - 12 the only one that didn't come out as January was number 1 which came out as December.
Any ideas?
Your logic is wrong. DatePart("m"... ) wil return an integer and then you are
attempting to apply a date format to that integer. In other words the output of
DatePart is not an appropriate input to the Format() function when trying to
apply date formats.
As far as the Format function is concerned you are passing in the date
represented by the number 3 which is the 2nd of January 1900. Just use...
Format([DateAffirmed],"mmmm")
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David |
last post by:
Hi Group,
i am trying to use the DatePart function on my SQL2000 database. I have a
table called visitors with a field called DateTimeEntrance which is filled
everytime a visitor enters the site. I am trying to build a stat page where
i display the total amount of visitors per day, week, month, year and i
can't seem to get the syntax...
|
by: Tipple |
last post by:
I'm trying to increment between the end of lunch and the end of the day. The
code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and
14 instead of 2:00:00 PM etc..
If response.write just counter2 I get a real hour.
How can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
|
by: sdowney717 |
last post by:
The field itemdate is a datetime field in sqlserver2000 DB
This works fine:
Select Id From BookData Where (MONTH(itemdate) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order by
TitleDuplicate
This does not work:
Select Id From BookData Where (MONTH(itemdate) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) =...
|
by: sean |
last post by:
Hi All,
I have one table TABLE1 in access2k on machine PC1, that has one
column named DO_DATE with "Date/Time" data type. Two other machines
PC2 and PC3 also running access2k. Each PC has its own data entry
form, and each form would execute the following insert query
independently:
INSERT INTO TABLE1 (DO_DATE, ... )
SELECT...
|
by: simon |
last post by:
There is DatePart function in VB, which returns minute or day or month,.. of
the selected dateTime..
Is there some similar function in C#?
Regards,S
| |
by: S. van Beek |
last post by:
Dear reader,
With DatePart() you can subtract the year or the week from a date field
with:
DatePart("yyyy";) for the year
|
by: funfair |
last post by:
Hi,
I'm facing a strange problem in access 2003 i dont know how to solve it
i have a code in VB which give an autonumber but in finanical new year
it reset to 1 on new year it works in one form but the same code doesnt
work in other form in run time it's going to skip if satatement of date
part to check if month is 4 or not
what is the...
|
by: Ryan |
last post by:
I just discovered this, as the new year rotated in.
I've got a little snip like this
TXT.Caption = DatePart(m, Date - DateReceived)
Well, it works fine, say if the DateReceived is 1/1/06 and it's
currently 12/1/06 it'll say 11.
However, now that it's 2007, I have a date that's 12/15/99 and it's now
|
by: grabit |
last post by:
Hi Peoples
I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007
i have 2 drop down boxes to select the listedmonth and listedyear on the refering page
I need to be able to retrieve this so i can send out renewals to those listings for another year.
I am using...
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |