I am using spreadsheetformatcellvalue to enter the date in the excel like this
<cfset spreadsheetSetCellValue(objxls, "#datecreated#", 2,1,"Date")>
it works, but i noticed something, i have two machines and in one machine date is displaying as: 02-19-2021
and in other excel it is showing 19/02/2021
what i noticed is that it seems to be using the locale specified of the windows. how can i force to use the format of dd/mm/yyyy across all machines irrespective of locale
can i use something in ColdFusion to make it work..
Thanks
You should be able to just format the date.
<cfset spreadsheetSetCellValue(objxls, "#dateFormat(datecreated, 'dd/mm/yyyy')#", 2,1,"Date")>
Related
I have a PowerBI report built in PowerBI desktop and displaying in a .net app using javascript. We have basic cards with decimal values formatted as currencies or percentages (in the formatting ribbon in PowerBI desktop). When the embedded report first displays in the web app, the formatting symbols ($, %) show for a split second and then disappear. I've removed layout and any extra style sheets and javascripts from the page, but still get the behavior. Have also set the localSettings in the JS config. Any ideas?
It's not a great solution, but a potential workaround would be to format the values using the FORMAT function which changes them to be text strings in the format you define rather than numeric values that get formatted however it decides.
For example, if you have a [measure] you can define another one like this:
measure_formatted = FORMAT ( [measure], "$ #,0.00")
Have string "09/07/2019 20:40:01 EDT"
Run command in SAS EG 7.1 connecting to a remote UNIX server
input(substr(event_time, 1, length(event_time)-4),anydtdtm23.) format DateTime23.3 as event_time
One machine comes back correctly as Sep 07, 2019. (dropping the time bit for clarity)
The other machine comes back as July 09, 2019.
Based on what I've read in related questions it seems to be caused by locale setting
What governs SAS locale setting ? Is it my OS ? the Remote UNIX server ? Something in SAS EG settings ?
Thank you
Don't use a guessing procedure unless you must. The ANYDT... series of informats will assume that ambiguous MDY or DMY stings follow the custom of the current language settings of your SAS session. So if SAS thinks you are in England then '09/07/2019' looks like the 9th of July. But if you are in the US then it looks like September 7th.
Instead read the string using either the MMDDYY or DDMMYY informat, depending on what format the strings are actually stored in. If your source actually is using mixed month day ordering styles then write code that uses information from your data to pick the right informat for a particular observation instead of forcing SAS to use your session setting to decide which one to use.
I've recently started using SAS Enterprise guide and would like to convert the date "01MAR2014" to "MAR 2014". I've been googling but unfortunately no luck.
I've tried the following however it just returns an
SELECT input(put(StartDate,EURDFMYw.),9.) AS Order_DDD_YY
Does anyone know how to convert this?
If your date is a SAS date, i.e. a numeric with date format applied then you can change the display by using the monyy5. format instead. Note that this will create a character variable that will no longer sort properly in reports/datasets, it will sort alphabetically instead of a date order.
put(startDate, monyy7.) as Order_DDD_YY
Otherwise you can apply the format instead of converting it.
I have data inside SAS.
I want to store the datafile to SPSS format (*.sav)
I use the following program:
PROC export Data=SASdataToStoreInSPSS
FILE="Path\Filename_%sysfunc(today(),date9.).sav"
dbms=sav replace;
RUN;
This works great. Except when I open the file in SPSS the dates are strangly formatted.
For example:
156405 08:51:00
Should be
3-Jan-2011 08:51
I can manually change the data formats in SPSS. So the values are correct date values, except they are not automatically formatted in a readable format.
I tried to change the format in SAS before saving to DATETIME20. or DATETIME23.3. But this does not help.
I want this to work without having to open SPSS and run a Syntax there.
The SPSS files that SAS spits out have to be directly mailed to other users of the data.
I think this is either a bug with SAS's export, or an issue with SPSS where some default changed. What's happening is that SAS is storing it as a SPSS Date - but with width 16, which is not long enough to hold the complete datetime. I don't think you can use DBDSOPTS with DBMS=SPSS, so I don't know that there is a good workaround short of importing the file into SPSS.
You could do that automatically, though, using the SPSS Production facility; I've written an import script before and asked SAS to run spssprod with the batch file. That's an irritating workaround, but it might be the easiest, unless SAS Tech Support can help you (and certainly try that - they are usually only a few hours' turnaround for initial contact at least).
SAS mentioned it has to do with the SPSS driver they use. Apparently it is not an easy fix so they forwarded the issue to second-line tech support.
The workaround you will need is split the dates in two columns. One with date and one with time.
data SPSS2;
set SPSS;
date = put(datepart(DatumSPSS), date9.);
time = put(timepart(DatumSPSS), time8.);
run;
Or you can tell the end user how to change the format of the date in SPSS.
For an automated approach, try this .NET app. You need SPSS, but SAS is not required to convert a large collection of SAS files automatically.
Manual Process included code samples or Application Download
I am working with a DB2 database for the first time.
I am trying to work with DB2 dates, but the data is stored as a string in the DB2 database.
I want to convert this date-string into an actual date, preferably dropping off time because I want all transactions between 1 Jan 2011 and 26 Jan 2011.
So essentially, I want this MS SQL statement in DB2 magic...
CONVERT(datetime,SETTLEMENTDATE.VALUE,103)
For background, I have got as far as
CAST(SETTLEMENTDATE.VALUE, DATE)
AND
DATE(SETTLEMENTDATE.VALUE)
But I need the expert knowledge of a DB2 whizzkid!
Thanks
Based on your own answer, I'm guessing that your column has data formatted like this:
'DD/MM/YYYY HH:MI:SS'
The actual separators between Day/Month/Year don't matter, nor does anything that comes after the year.
You don't say what version of DB2 you are using or what platform it's running on, so I'm going to assume that it's on Linux, UNIX or Windows.
Almost any recent version of DB2 for Linux/UNIX/Windows (8.2 or later, possibly even older versions), you can do this using the TRANSLATE function:
select
date(translate('GHIJ-DE-AB',column_with_date,'ABCDEFGHIJ'))
from
yourtable
With this solution it doesn't matter what comes after the date in your column.
In DB2 9.7, you can also use the TO_DATE function (similar to Oracle's TO_DATE):
date(to_date(column_with_date,'DD-MM-YYYY HH:MI:SS'))
This requires your data match the formatting string; it's easier to understand when looking at it, but not as flexible as the TRANSLATE option.
I know its old post but still I want to contribute
Above will not work if you have data format like this 'YYYMMDD'
For example:
Dt
20151104
So I tried following in order to get the desired result.
select cast(Left('20151104', 4)||'-'||substring('20151104',5,2)||'-'||substring('20151104', 7,2) as date) from SYSIBM.SYSDUMMY1;
Additionally,
If you want to run the query from MS SQL linked server to DB2(To display only 100 rows).
SELECT top 100 * from OPENQUERY([Linked_Server_Name],
'select cast(Left(''20151104'', 4)||''-''||substring(''20151104'',5,2)||''-''||substring(''20151104'', 7,2) as date) AS Dt
FROM SYSIBM.SYSDUMMY1')
Result after above query:
Dt
2015-11-04
Hope this helps for others.
In format function your can use timestamp_format function.
Example, if the format is YYYYMMDD you can do it :
select TIMESTAMP_FORMAT(yourcolumnchar, 'YYYYMMDD') as YouTimeStamp
from yourtable
you can then adapt then format with elements format foundable here
Okay, seems like a bit of a hack. I have got it to work using a substring, so that only the part of the string with the date (not the time) gets passed into the DATE function...
DATE(substr(SETTLEMENTDATE.VALUE,7,4)||'-'|| substr(SETTLEMENTDATE.VALUE,4,2)||'-'|| substr(SETTLEMENTDATE.VALUE,1,2))
I will still accept any answers that are better than this one!
You can use:
select VARCHAR_FORMAT(creationdate, 'MM/DD/YYYY') from table name