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
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
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.
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!
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.
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
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
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.
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?
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
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)?
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?
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 :
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.
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.
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,
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.
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
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?
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:
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?