How to Convert Date with ZZZ - nsdate

I'm want to query for an object in my CoreData using NSDate.
I have an string like "2013:32:17 06:32:24 -0300".
When I get the object and convert it using "[format setDateFormat:#"yyyy:mm:dd hh:mm:ss ZZZ"]" I get a string like "2013:32:17 09:32:24 +0000"
How do I convert to the same original format above (-0300 ???)
Tk's!!

Related

Convert string to date format in azure data factory using set variable

I have string date in set variable "20211222"
And I want to convert it into date like 2021-12-22.
And I have use this function in variable set dynamic content
#formatDateTime('20211222', 'yyyy-MM-dd')
But error occur In function 'formatDateTime', the value provided for date time string '20211222' was not valid. The datetime string must match ISO 8601 format
Is there any other function to convert this string "20211222" into date?
Actually the string '20211222' is already in the unambiguous format of YYYYMMDD and will always be interpreted this way. If you need to use this string input as a date, just do a cast:
SELECT CAST('20211222' AS date); -- 2021-12-22
If you wanted to formerly go from your text input YYYYMMDD to a text output of YYYY-MM-DD, then make a round trip:
SELECT CONVERT(varchar(10), CAST('20211222' AS date), 120);
Function formatDateTime expects "a string that contains the timestamp".
Example:
formatDateTime('03/15/2018 12:00:00', 'yyyy-MM-ddTHH:mm:ss')
You would have to manage to input in a timestamp format. The default format for the timestamp is "o" (yyyy-MM-ddTHH:mm:ss:fffffffK), which complies with ISO 8601 and preserves time zone information.
Please use the below logic:
#concat(substring(pipeline().parameters.Test,0,4 ),'-',substring(pipeline().parameters.Test,4,2),'-',substring(pipeline().parameters.Test,6,2))

MongoDB script to convert String "09-Jan-20" // (DD-MMM-YY) into ISO Date

I have multiple records in a collection and date is stored as String as "09-Jan-20". I need to convert this date into ISODate by script execute on MongoDB.
exp: "09-Jan-20" to ISODate("2020-01-09T00:00:00.000Z").
Anyone, please help.
Got the solution for this question.
We can use mongo's $convert to convert the string into date format.
Exp:
"$convert":{
input: "$dateField",
to: "date"
}
We can also find out the records where date is in string format by-
"$type":"string"
Refrence:- mongo type check and mongo convert

How can I store String type DateTime string to ISO DateTime Format in MongoDB in NodeJS?

I am receiving a string format DateTime Strings data from the android app.
according to the previous developer's note, it's RFC 3339 format string.
I am stuck in converting this string into MongoDB's Date format in Node.js
in detail edit documents, formats are like below.
[ current string what I receive -> Date format in MongoDB, which I wanna store]
[ "2020-09-14 08:18:56", -> ISODate("2020-09-14T08:42:41.000Z") ]
Is there any way to save those strings into MongoDB on NodeJS programmatically?
RFC 3339 is a profile (a set of standards derived) of ISO 6081 (see these SO posts: [1], [2]), so you can just pass the string to Date's constructor and get a valid js Date:
var raw = "2020-09-14 08:18:56";
var date = new Date(raw);
console.log(date);

Grails - converting a String to Date and then back to String

I've got this string 21-04-2016 for instance, that I'm trying to convert to a date. After that's done I need to flip it around, remove all the dashes and then convert it back to a string so that it looks like 20160421. I have found some code that I'll post below but I want to know if there is a simple way of doing this, maybe without having to convert the string to a date? Anyhow, here's my (broken) code:
String from = region.startDate //I get this string from a controller
Date fromDate = Date.parse('yyyy-MM-dd', from) //.parse is depricated apparently
println(from)
println(fromDate)
Here's what I get back (from the println):
Wed Jul 08 00:04:00 SAST 16
11-04-2016
No need to convert from String to Date in that case (you could use a SimpleDateFormat (or rather two) to do that, though); just use String and List operations from Java and Groovy:
from.split('-').reverse().join()

Error in converting string to datetime in C#.net

I am getting an error in converting string to date in C#.
The error is:
string is not valid datetime.
Below is the code that I am using to convert string into datetime.
string[] DateFormat = { "dd-MM-yyyy", "dd/MM/yyyy", "MM-dd-yyyy", "MM/dd/yyyy" ,"dd-MMM-yy"};
VendorSinceDate = DateTime.ParseExact(dtresult.Rows[0]["VendorSinceDate"].ToString(),DateFormat,System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None);
//dtresult.Rows[0]["VendorSinceDate"].ToString()="06-Jun-12 12:00:00 AM";
None of your possible DateFormats include the time, but the string you're trying to convert does.
You need to add a matching DateFormat, e.g. dd-MMM-yy hh:mm:ss tt

Resources