How can I tell Access once & for all that I am in Belfast UK and not Belfast ME? To illustrate my problem, I have created a table containing the dates of each day in 2012. If I run this query
SELECT *
FROM tblListOfDays
WHERE dtmDay BETWEEN #01/05/2012# AND #31/05/2012#
148 rows are returned, all the dates from 5th January to 31st May. So Access is reading one date in US format, and the other (presumably because it is has no choice) as UK format. If I use
Format("01/05/2012", "dd/MM/yyyy")
instead of
01/05/2012
then I get the answer I want, but surely there is a simpler way than having to use Format all the time? All my regional/locale settings are UK as far as I can check.
as petr-abdulin said you can use
Format(expression, format)
So your code becam :
SELECT * FROM tblListOfDays WHERE Format(dtmDay, "dd-mm-yyyy") BETWEEN
Format("01/05/2012", "dd-mm-yyyy") AND Format("31/05/2012", "dd-mm-yyyy")
and dont forget to use format while inserting also.
and here you can find more info about this function.
AFAIK there is no other way than to specify date format explicitly using Format function.
Related
Is there a way in Semantic Mediawiki to store and use relative dates?
I would like to store genealogical data in Semantic Mediawiki and there is sometimes information like: »On January 10th 2021 John, son of the deceased Jack, married Mary.« Now I know that Jack died BEFORE 2021-01-10. Is there any way to store (and query) such information -- BEFORE 2021-01-10 -- in a date property, just like in GEDCOM format?
To store such data, you can define Record datatype:
Property:Relative date of birth:
[[Has type::Record]]
[[Has fields::Sign;Date value]]
Property:Date value:
[[Has type::Date]]
Property:Sign:
[[Has type::Text]]
[[Allows value::Before]]
[[Allows value::Exactly]]
[[Allows value::After]]
To store data, use [[Relative date of birth::Before;January 9th, 1976]].
Querying such data is not an easy task. For an exact day, use {{#ask:[[Relative sate of birth::Exactly;January 9th,1976]]}}. To query for people born before the 9th of January 1976, you need a more complicated query, or a union of queries: {{#ask:[[Relative sate of birth::Exactly||Before;<January 9th,1976]]|?Relative date of birth.Date value=date}}.
I have a set of functions for "GEDdates" I store dates with two fields, one for the date in ccyymmdd format and another for a modifier. The date can be truncated if you don't have specifics: ccyy or ccyymm. The modifiers are <, >, c, - for BEF, AFT, ABT and BTW in GEDCOM. The - is followed in the modifier field by the later date such as -ccyymm. I've recently also used the Unicode character for between ≬ (≬) which is more aligned with the data type.
This data structure gives all the flexibility needed. There are code examples at GitHub
I'm using node.js to select info from my mysql database and I have a datetime column, but I'm not getting the format I want.
This is my sql code
SELECT id, data, titulo, subtitulo, texto, DATE(datahora_cadastro) as data FROM sig_noticias
I need the data to be like this: DD/MM/YYYY
But I'm getting this: Thu Mar 30 2017 00:00:00 GMT-0300 (GMT-03:00)
Easiest way to format dates in Javascript is by far using a modern date / time library. I personally use MomentJS and it works well. I highly recommend this solution if you plan on working with dates in even just a few areas of your app.
Using moment, you could simply call moment(myDate).format("DD/MM/YYYY");.
If you really want to stick to pure Javascript, however, here's how to get the format you want:
const formattedDate = `${myDate.getDate() + 1}/${myDate.getMonth() + 1}/${myDate.getFullYear()}`;
Javascript's built-in date functions are pretty confusing. Here, for instance, the getDate and getMonth methods return the index of the date / month, and not the actual date / month, so we need to add +1 to those.
Using vanilla Javascript then becomes even harder when dealing with date manipulation (adding, subtracting) and timezones.
I'm trying to setup a query that will show me all of the records in a particular table where the listed expiry date is either in the past or upcoming in the next 6 months (approximately).
At the moment, I have the "Expiry" field added to my query and the 'Criteria' as .
When I try to save the query, I get the following message:
Access can't evaluate an expression or convert data because data types aren't compatible with each other.
TECHNICAL DETAILS
Correlation ID: ae68949d-3041-3000-0984-71635f8fd670
Date and Time: 7/28/2016 6:54:34 PM
I've tried searching the web for a solution, but most websites refer to the Date() function that doesn't seem to be available in the Access 2016 Custom Web App. When I take out the "+180", it works fine but obviously doesn't give me what I need.
Any help would be appreciated.
=============================
UPDATE:
Some users have asked for my SQL and Table Design details. I don't seem to have any way of accessing the SQL View (the option doesn't appear), but here's a copy of my table view:
Access Query Table Design
In the table, 'Active' is a Yes/No field and 'Expiry' is Date/Time.
Try
< DateAdd(Day, 180, Today())
as criteria.
According to https://msdn.microsoft.com/en-us/library/office/jj249452.aspx this should work in a custom web app.
Error says that you have two different date types and they can't be compared. so, as the Today() returns only the Date with 12:00 pm, I can guess that your other "Expiry" Field is a datetime type. So, you can do either: use Format function to convert datetime to date like this
Format([2/22/2012 12:00 PM],"dd/mm/yyyy")
or use Now() function which returns datetime,
or Share your Code :)
I make with Excel a MSQuery to obtain some fields from a table in MySql what is working fine but there is one column which has in MySQL a time-format and Excel delievers me this in datetime-format.
I can format the cell in Excel so that it shows me the time in format hh:mm that is not the problem but I had to use these fields from the database to do some calculations in Excel which leads to my problem: I can't make a sum over these fields when the sum is greater then 24 hours, because then I get only the value of the hours and not from the days multiplied with 24 (e.g. instead of 25:15 I get only 1:15).
Normally I use for this format [hh]:mm so there will be displayed all values (even for more then 24 hours) but this doesn't work here, because I get a very high value (for example: 1017144:15). The reason for this is, that Excel adds for every field to the time the acrtual date of today (e.g. 12:00 will be 12.01.2016 12:00) and with this for every time in the sum the value for the date will be add additionally.
I tried it with the following statement in the MSQuery:
SELECT
DATE_FORMAT(entry.timeBegin, '%h:%i') AS 'Beginn',
entry.timeEnd AS 'Ende',
TIME(entry.pause) AS 'Pause'
FROM timetable.entry entry<br>
All 3 columns have in the database in MySQL the format hh:mm. Ende and Pause behaves like described above and Beginn is formatted in the right way (just without formatting the field by Excel) but the content of the field has type string and with this, Excel always use 0 (zero) for these fields when calculating with them, so I get allways 0 as sum.
I know that I can build the sum in MySQL, but this is no solution for me because the user could set some filters in Excel and this is to complicated to build in the query, espacially this is only one part of a more difficult construct.
Ok, here are a few examples. 'Beginn' allways delivers 0:00 (as described above) and 'Ende' and also 'Pause' are allways equal together. So we have to consider Ende or Pause with hh:mm and [hh]:mm format:
0:00 leads to 0:00 / 1017144:00
1:30 leads to 1:30 / 1017145:30
20:00 + 3:00 leads to 23:00 / 2034311:00
21:30 + 3:00 leads to 0:30 / 2034312:30
I didn't try PowerQuery because I don't know it till now and I don't know if it is inside of Excel or MS. I don't want to install an additional tool on the PC for every user. If I had only to take it into my Excel-sheet so it could be a solution if it is functions right.
Supplement: I looked after PowerQuery and see that this will bring me problems, because the most users uses MS Office 2010 and the requirement with Excel 2010 is Microsoft Office 2010 Professional Plus mit Software Assurance and the feature Software Assurance is not present in our company.
Added: For more clearness I add a screenshot from Excel:screenshot of Excel
I get column A from SQL displayed in format h:mm.
Column B is the same just in number-format.
D2 and E2 are the Sum from A1:A10 in format h:mm respectively [h]:mm:ss.
D3 and E3 are the Sum from A1:A23 in format h:mm respectively [h]:mm:ss.
As you can see SQL delievers the Time 5:30:00 via MSQuery and Excel shows me 14.01.2016 05:30:00 which I can format in the right way (column A). Building the sum is possible (look D2) as long as it is smaller than 24 hours else I get only the hours (< 24) which are greater than a entire day. The reason for this you can see in D3 and E3.
What can I do to get the right values? I suppose the easiest way would be at the point of getting the data from MSQuery.
I am trying to build a calculated field for a web database in Microsoft Access 2010.
The field should show the day in a three character format as follows:
Mon
Tue
Wed
from an existing date column in the table.
Obviously the Format function is not compatible with the web. And the following function FormatDateTime does not have the option to convert to a string day, just a long and short date and time.
Any ideas on how this can be accomplished?
If this is not possible my only option seems to be to create a client object.
I have tried adding the function into a query instead but this is also incompatible with a web database.
WeekdayName should suit. Be careful with FirstDayofWeek:
SELECT WeekdayName(Weekday([ADate],1),-1,1) FROM Table
Syntax:
Weekday(Date,[FirstDayOfWeek])
WeekdayName(Weekday as Long,[Abbreviate as Boolean],[FirstDayOfWeek])
1 = Sunday in both of the functions.