powershell get current date format being used by system - powershell

How can I use powershell to get the current system date format for example if I was reading a log file using powershell I would like to know if 2012-03-01 is in yyyy-mm-dd or yyyy-dd-mm.

This should give you the DateTime formats for the machine's current culture:
[cultureinfo]::CurrentCulture.DateTimeFormat

Related

Azure Data factory not able to convert date format

I'm trying to get DAYID as string in format YYYYMMDD, however its not working correctly.
I have a timestamp field, I take first 10 characters and convert it into date (working correctly)
toDate(substring(EventTimestamp,1,10))
-- 2021-03-24
However when I try to convert to string using below expression, I;m getting wrong answer. I;m getting the Day as 83.
toString(toDate(substring(EventTimestamp,1,10)),'YYYYMMDD')
--20210383
Date format characters are case-sensitive as per this answer here, so use yyyyMMdd instead.
An example using formatDateTime:
#formatDateTime(utcnow(), 'yyyyMMdd')

Bash script to modify the last modified date using the file name

I downloaded all the pictures from an old spanish social network and the Last modified date is the date that I downloaded the file instead of the real date. I would like to order all the pictures by Last modified date to upload to google photos using the correct date.
I know the real date because the image name has the date and time and I would make a script to change de last modified date using the name of the file. I don't care about the time.
Name of the file format: "yyyy-mm-dd hh-mm-ss.jpg"
I'm using windows, but is not a problem to install Unix to execute some bash script, because it may probabbly be easier.
Is there any way to do this?
Thanks in advance
You can use powershell $(Get-Item *Filename*).creationtime=$(Get-Date "mm/dd/yyyy hh:mm am/pm") in a batch file or command prompt to change the creation date of a file. for more information look at this. In your case you could do:
for %%i in (<folder with all the files path>) do (
set name=%%~i
set name=%name:~0,19%
powershell $(Get-Item %%~i).creationtime=$(Get-Date "%name:~5,2%/%name:~8,2%/%name:~0,4% %name:~11,2%:%name:~14,2%")
)
Note: I have not tested this since I do not have the data set for it.

Getting date format from string

I have what I think it's a simple question.
I have a file named like this: 'prec/CHIRPS/P_CHIRPS.v2.0_mm-day-1_daily_2020.01.01.tif' and you can see it has a date within.
I've used successfully the package datefinder to extract the date from that string, but now what I want to do it's actually get the format from which datefinder read that date. That means that I want an output to be '%Y.%m%.d%' so I can use it to write a file with that same date format.
This is for example to be able to use whichever format of date and whichever file name I have, extract both the date and its format, and finally rewrite something like 'this is just an example of the file name with the date 2020.01.01'.
Thanks!!

In RPG, use a date, in *job format from a file

I'm trying to convert, in a RPG program, a date from a file (it's from the DSPJRN command, so the field si 6 numeric, in JOB format).
I want to use it as a date in my program, but I can't achieve it correctly.
I have tried to describe a field with type "D": date, keyword datfmt(*job) to convert the value from the file, but datfmt(*job) is incorrect (error RNF0612)
I have tried to retrieve the job Date format from a CLP program with RTVJOBA DATFMT(&FMT), and use the variable in RPG to convert the date like this
eval ztJODATE = %date(JODATE:FMT)
but it doesn't compile : error RNF0606 . I think that I can't use a variable for the format in the %date built-in function.
Is this a way to do what I want, or am I forced to transform the date value in SQL before using its value in RPG?
PS: I don't want to hardcode the format in my RPG program!
You can specify *JOBRUN for %DATE.
eval ztJODATE = %date(JODATE:*JOBRUN)
Note that RPG retrieves the job date format during initialization of the module, so if you change the job date format while the program is running, RPG will not understand the date.
Rather than using DSPJRN to an outfile, the recommended way to retrieve and process journal entries would be to use one of the programatic interfaces provided by IBM i.
Retrieve Journal Entries (QjoRetrieveJournalEntries) API
QSYS2.DISPLAY_JOURNAL() stored procedure
You could also use a *TYPE3 or higher format for the output file. Rather than the separate job formatted data & time fields, there's a single char(26) system timestamp field.
Having said that, there is a Convert Date and Time Format (QWCCVTDT) API that accepts '*JOB' as an input format specifier..

CMD echo %date% returns '/Tu' instead of a proper date

I am generating the date in a format of YYYYMMDD so that i can append it in the filename that the batch program generates.
But in my local system echo %date% returns
echo %date%
Tue 09/08/2015
The date information is returned so i can modify it the way i want
In server, the same does not return date values
echo %date%
/Tu
I dont have date values to modify it to my required format YYYYMMDD
How do I go about this? Is there any Windows date and time setting that i should be looking at?
The date format depends on the regional settings of your machine. You can check them in control panel (run intl.cpl), they seem to be broken.