Converting Date Function For Both UK & USA

Dec 15, 2006

This function gets the last working day (Mon-Fri Are Deamed Working Days For Invoicing purposes) of a month adds it to a table then gets the next until it has done the Number indecated In "txtMonths", It works with a UK Date Format but not with a USA Date Format.

Is there A Better way of doing this or does anybody have an idear as to how I could correct it for UK and US Date Formats

Y = Year(Me![txtStartDate]) 'Get Added Year
M = Month(Me![txtStartDate]) 'Get Added month To Keep Track Of year Change
D = Weekday(Me![txtStartDate], vbMonday) 'Get Day of week and set to monday
On Error Resume Next
For C = 1 To Me![txtMonths]
DDt = CDate(1 & "/" & M & "/" & Y) 'Set to first of the month
Ld = LastOfMonth(DDt)
Nd = CDate(Ld & "/" & M & "/" & Y)
'StrSch = Ld & "/" & M & "/" & Y
CWd = Weekday(CDate(Ld & "/" & M & "/" & Y), vbMonday)
'Now If the date falls on a sat or sunday move the day back to friday
If CWd > 5 Then
If CWd = 6 Then D = 1
If CWd = 7 Then D = 2
Nd = CDate(Ld & "/" & M & "/" & Y) - D
End If
AddSchedule Nd
'Debug.Print C & " | " & StrSch & " | " & CWd & " | " & Nd & " | " & D
M = M + 1
If M > 12 Then
M = 1 'Only 12 Months in a year
Y = Y + 1 'Gotta be a new year Happy New Year
End If
Next C

Edit: Function used to get the last day of a given month

Function LastOfMonth(InputDate As Date) As Integer
' Return a date that is the last day of the month of the date passed
Dim D As Integer, M As Integer, Y As Integer

If IsNull(InputDate) Then
LastOfMonth = Null
Else
D = Day(InputDate)
M = Month(InputDate)
Y = Year(InputDate)
'find the first day of next month, then back up one day
LastOfMonth = Day(DateAdd("m", 1, DateSerial(Y, M, 1)) - 1)
End If
End Function

View Replies


ADVERTISEMENT

Converting A Text Date String To A Date For Calculations

Jan 7, 2005

Hi there. I'm just jumping into Access and have the following question. In my Purchase Order Table, I have a date field calcualated as text, i.e. "01/12/04". I need to convert this to a date format in my queries so I can do calculations, i.e. 01/12/04 - 01/05/04 = 7 days. Can someone help me with how to convert this text date to a date format. Sorry if this is an easy question. - AJS

View 4 Replies View Related

General :: Converting Date / Time Field Into Date

Dec 9, 2014

How can I convert a Date/Time field into a Date field?

View 4 Replies View Related

Converting Text To Date

Jul 13, 2006

Hi, I have the following problem which I hope someone can help me with:

I am importing a CSV file, one of the field in which contains times in the following format: 1200 (ie this is 12:00, th text file does not contain the : separator)

I want these to be recognised as time values by access, which at the moment only treats them as text. Is there any way i can run a query on this table to convert the numbers into times? I can do it in excel using concatenate to add in the :, but access does not have this function.

Thanks in advance!

View 2 Replies View Related

Converting Text To Date

Jan 24, 2007

Hi there,

I have a table with a field called 'dereg_date' which is formatted as text, an example is as follows:

2006-07-07 00:00:00.000

I want to be able to convert this field to a date. I have tried using a query with Cdate([dereg_date]), however it doesn't convert it and just returns #Error for all the records.

Has anyone got any ideas on this? I need this fixed fairly urgently as my superiors are getting quite impatient!

Many thanks in advance!!
Sasha.

View 4 Replies View Related

Converting Two Date/time Fields To One Integer

Sep 15, 2006

Hi,

I'm combining two date/time fields in a query to an integer. The first field has the date, the second the time. I'd like the resulting integer to be without the opening 0. How can I do that?

That is, these are the two fields:
2006-09-14 (date/time)
15:00:20 (date/time)

And I'd like those two combined to be 60914150020 (integer) in the third field in the query.

Grateful for advice!

View 3 Replies View Related

Queries :: Converting Four Digit Numbers To A Date

Jul 30, 2014

I have a query to create in access based off a query already created in SQL

The SQL query converts a 4 digit number into a date using this code:

CAST(CASE WHEN LEFT(OPDT, 2) > 12 OR LEFT(OPDT, 2) = 00 THEN RIGHT(OPDT, 2) ELSE LEFT(OPDT, 2) END + '/' + '01' + '/' + CASE WHEN LEFT(OPDT, 2) > 12 OR LEFT(OPDT, 2) = 00 THEN LEFT(OPDT, 2) ELSE RIGHT(OPDT, 2) END AS SMALLDATETIME)

OPDT is a digit number in text format. The function converts 9606 into 1996-06-01

What is the access method in order to this?

View 7 Replies View Related

Modules & VBA :: CDate - Converting String Into Date

Nov 12, 2013

I would like to convert 2013.11.13 which is a string into a date. This is what i have so far but it's not working.

2013 year

11 month
13 day of week
Dim strDate As String, dteConvertedDate As Date
strDate = 2013.11.13
dteConvertedDate = CDate(Mid$(strDate, 6, 2) & "/" & Left$(strDate, 4) & "/" & Right$(strDate, 8))
MsgBox (dteConvertedDate)
End Sub

View 7 Replies View Related

Tables :: Converting Text To Date Format During Import

Jun 17, 2014

I am building a database using data imported from Excel workbooks. The dates in the workbooks are formatted as text in the YYYYMMDD format. Is there a way to convert this into date format during the import or after? I am pulling in a lot of different workbooks and trying to avoid having to reformat each individual workbook prior to importing them.

View 3 Replies View Related

Converting Yyyymmdd Dates To Serial Date Number

Sep 5, 2011

I have two tables that I want to append to each other.But in one of them the date column has the yyyymmdd format and in the other it is a serial date number.How can I make them consistent by either converting yyyymmdd to date number or by converting the date number to yyyymmdd?

View 1 Replies View Related

Date Function/need Time Function

Jun 9, 2005

We have a date function that converts a text date format. Can someone help me with time function to do the same thing? We want military time. The field is like this now: txt fields.
160037
213137
224356
235716
235800
12341
21708
22732
Here is the date function we use:
Function f2Date(strDateOld As String)
Dim strDate As String, strMonth As String, strYear As String
strMonth = Mid(strDateOld, 5, 2)
strDate = Right(strDateOld, 2)
strYear = Left(strDateOld, 4)
f2Date = strMonth & "-" & strDate & "-" & strYear
f2Date = CDate(f2Date)
f2Date = Format(f2Date, "mmmm d yyyy")
End Function

View 9 Replies View Related

Now Function To Convert To Date Function

May 25, 2006

Hi all,

I need a little help. In my DB, I have a command button set up (I was tired of typing in dates) for date, but I used the Now function, which also gives me the time.

Now I have over 3000 subrecords of the main ones. I now need to queries transaction for that specific date, but it also retrieves the time.

I tried to go back and change the NOW to DATE in VB, but the code does not run.

How do I change all records that have date and time (using NOW function) and only click that command button to show only the date (mm/dd/yyyy)?

Thanks in advance.

View 1 Replies View Related

Problem Converting Date Stored As Text To Data/time Format

Sep 9, 2005

I have a problem converting text to a real date value so I can do some calculations. I have a query that brings in data from an external data source. It appears the data is stored in the external table in text format and looks like this:

20050902 15:40:41

I have tried CDate to convert the text to a date/time format, but no luck. Any ideas?

View 5 Replies View Related

Modules & VBA :: SQL Server - Conversion Failed When Converting Date And / Or Time From Character String

Feb 13, 2014

I have two table

1. dbo.period (OpeningDate, ClosingDate)
2. dbo.data (blah blah, doc_date)

I want to create a view as follows

Select doc_date from dbo.data
where doc_date> 'select OpeningDate from dbo.period'

both doc_date and opening date have the same format

but the error will still appear as follows:
"Conversion failed when converting date and / or time from character string."

View 3 Replies View Related

Queries :: Converting CSV File Into Text Format - Export Records With Specific Series And Date

Jun 7, 2015

I have a CSV file and want to convert it in a text format with some filtered data and with some formatting. This is an everyday task for me. So I made a table and imported the data in to it by the command :

DoCmd.TransferText acImportDelim, "fo Import Specification", "fo", FileName:="C:UserswelcomeDesktopfo.csv", HasFieldNames:=True

Actually I have a column "SERIES", contains various series like "EQ", "BE", "DR", "BZ", "D1" and so on. And one more column with the dates having 4 / 5 current months dates and one next months date and one next to next month's date. And every date has got several thousand records.

now the issue is that : After importing these several thousand records, I want to export it but with a specific date and with a specific series.

The other thing is that, these dates change every month so if hard coded, the problem will occur the next month.

I use this code for export :

DoCmd.TransferText acExportDelim, "NewFnoSpec", "fnoquery", "C:UserswelcomeDesktopFO Output.txt", True

this code is working fine but when the month will change, the code won't work.

Can we have a date & series picker attached to this query, so it can export the records with the specified SERIES & DATE.

I tried putting a textbox on the form named TxtDate and in a Query ( Design mode ) under the date column, in criteria I have put [Forms]![Futures]![TxtDate] and after putting this line, the query becomes empty and no data is there.

View 14 Replies View Related

Problems In Converting Date Field To Text Field

Jul 21, 2006

I have a strange problem of converting a date field stored as dd/mm/yyyy to a text[8] field. Example 01/06/1947 should be converted to 01061947. What is the easiest way of doing it? I tried changing it to first to ddmmyyyy and then change it to text, but it did not work.Can someone help me please?
Many thanks,

View 5 Replies View Related

General :: Converting A Text Field Into A Date Field

Feb 12, 2014

I have a text, date field I need to convert to a date field.For example: 2/11/14 is stored at text: 21114.How can I convert the 21114 into 2/11/14?

View 5 Replies View Related

In Between Date Function

Jul 26, 2005

Hi Folks,

I know this is possible, just not sure how to proceed or what function to use ... I have a normalized database of unique identifiers, admit data, and discharge date. I am attempted to count only the dates within a certain range between admit and discharge dates for each record. For example, I would like to compute the number of days someone was in admission between #07/01/03# and #06/30/04# only, not counting any days outside of that range.

So if a record has an admit date of 5/3/00 and discharge date of 12/7/03, the value returned would be 159 days, because that is the number of days between #07/01/03# and #06/30/04# the record was enrolled. If a records admit date is 01/01/01 and discharge is 07/26/05, the value returned would be 365 days.

Any ideas?

Thanks,

Joe

View 2 Replies View Related

Need Help With A Date Function.

Aug 2, 2007

Here is what I'm trying to do.

I need a function which takes the current day and finds the date of that weeks Sunday.

Then I need to take that date (of the Sunday) and subtract 13 weeks from it.

This is for the criteria in a query so that the only data displayed will be the previous 13 weeks worth.

Not quite sure how to go about this. TIA for the help.

View 3 Replies View Related

Date Function

May 18, 2005

Should this work? If not is there a way I can achive it! I think its fairly self explanetry :confused:

Private Sub Form_Open(Cancel As Integer)
Me.Date2 = Now()

If Me.Date1 < Me.Date2 Then
Me.Check8 = False
End If
If Me.Date1 > Me.Date2 Then
Me.Check8 = True
End If

End Sub

View 10 Replies View Related

Date() Function

May 23, 2006

Hi Guys,

Does anybody know the formula for validating a date in a DOB field.

I want it to only allow dates where the age is at least 18years old.

Something like '<Date()-18' (But a formula that works!)

Thanks in advance!

View 7 Replies View Related

Function Date() Isn't Work

Jul 31, 2005

I made a program for litle hotel registration. It worked enoudh good for me but after changing a comuter function Date() isn't work
In Build-In-Functios Date() persist but every try to use it cose massage "The function you entered can't be used in this expression"
In some queries I change Date() with Now() but can't do this in all.
HELP

View 3 Replies View Related

Problem With Date() Function

Dec 30, 2005

Since I use Access2000 my Date() function returns always the error "#name". Is there a fix for that?
I switched to using now() which is working, but it stores the date and time in the fields. Then the date searching is not accurate since the attached time increases the date by one day when I search for dates. I have to get the date() function back to work since I am also unable to format now() in a way that it kills the time portion of it. Any Ideas?

View 14 Replies View Related

WHY Am I Getting This Error? (Date Function)

Aug 12, 2005

I don't get it!!!! I use it all the time. <=Date() should get all rows with no future dates...but I get this error on some of my queries...I've never got this error before... :mad: :mad: :mad: :mad:

Sorry about the poor image quality.

View 1 Replies View Related

Format Date Function

Mar 23, 2007

Does anyone know of a function that will change the date format from yyyymmdd to mmddyyyy? I have a linked table to a data repository, I'm using a date field in a query and would like to use the dateadd function to return a certain date range from 7 days prior. I can't get it to run, I thought this might be due to the date format.

here is what i have in the date field as the criteria: <DateAdd("d",-7,Now())
the date field is formated to yyyymmdd
Any suggestions?

View 11 Replies View Related

Specifying A Date In A GoTo Function

Dec 7, 2004

On loading a form is it possible to Go To a record which is within 10 days of today's date?
DoCmd,GoToRecord,acDataForm,"frmClinics",?????????

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved