How can I convert the time since epoch to Hex in Go?
It should look like this: 5E839BAB
See: https://www.epochconverter.com/hex
EDIT: I was not able to find anything similar asked already. My Plan was to get the current time in Unix (Epoch) -> convert it to a Byte Array and then use hex.EncodeToString() to get it as hex
You can get the epoch of time value using t.Unix():
t:=time.Now()
fmt.Sprintf("%X",t.Unix())
To get this as a byte array:
import "encoding/binary"
...
out:=make([]byte,4)
binary.LittleEndian.PutUint32(out,uint32(t.Unix()))
Or, use BigEndian.
Related
I have a column of times in ALteryx like the following:
Time
=====
8:05 AM
8:07 AM
8:11 AM
8:12 AM
8:16 AM
...
They are currently stored as a String, but I want to convert them to the Time format. So far, I have tried using the LEFT and TRIM function to isolate the time itself as such:
Trim(Left([Time], 5)," ")
However, when I try to convert this to a Time datatype, I receive type conversion errors. How can I convert something like 8:46 AM from a String to a Time datatype in Alteryx?
I did some more digging and trying different things out, and I was able to figure it out. For the reference of others, here is what I did:
DateTimeParse([VisitTime] + " " + [PartofDay],"%I:%M %P")
Where [VisitTime] is the time expressed like 8:30 and [PartofDay] is AM or PM.
After this, I used a Select tile to change the datatype from String to Time without type conversion errors.
I know I can using the ConvertTimeZone function to convert but, it is possible to use addminutes to convert time zone?
I am new to freemarker.
In freemarker, I would like to perform arithmetic expression on DateTime as follows:
${triggerTimestamp}-1h
But this is not working. Could anyone please help here?
FreeMarker doesn't do date/time arithmetic out of the box (as of 2.3.30 at least). It's expected that the data-model (context) contains the values that you actually want to display. One can implement some helper method in Java though.
You'll want to explore converting the date into unix/epoch time. If you add ?long to the end of the variable you'll convert the datetime into epoch time (which is in seconds) then do math and convert it back to a date. Your example would be
${(triggerTimestamp?long - 1 * 1000 * 60 * 60)?number_to_datetime?string.iso}
Hello i've been working on how to get yesterday date in DataStage?
CurrentDate()-1
When i compile the job, it gave me an error.
So how should i do to get the yesterday date?
btw that code i'm doing it in the Transformer stage
Assuming you are using the parallel engine in DataStage - this could be a solution
DateOffsetByComponents
DateOffsetByComponents(CurrentDate(), 0, 0, -1)
As the last parameter is the day part and -1 would substract a day
Convert the date into a date type, then you can add or subtract days.
You can use IConv to convert a string into a datastage internal date format. Then you can perform addition/subtraction on the date. Then use OConv to convert the variable back to string format.
If this is done in a transformer stage, you need to do this all in one statement:
OConv(Iconv(VDate ,"D/YMD[4,2,2]") - 1), "D/YMD[4,2,2]")
Hope this helps.
In a parallel Transformer stage, I'd use DateFromDaysSince() function. Use current date function as the base, and -1 as the offset value.
I have data that I would like to represent as comma10.2 when less than 1,000,000 and e10. when greater than or equal to 1,000,000. It seems like there might be a way to do this using the picture format, so I thought I might also making missing values show up as --. This is what I've got so far:
proc format;
picture DashMiss . = '--' (noedit)
low - <1000000 = "000,009.99"
1000000 - high = ????;
run;
I'm not sure how to represent scientific notation using picture (hence the question marks). I don't have to just use picture if there's an easier way to do it.
I figured out how to use brackets to add the conditional format:
proc format;
picture DashMiss . = '--' (noedit)
low - <1000000 = "000,009.99"
1000000 - high = [e10.];
run;
I believe you could've simply used the best6. format or bestd6.2 to achieve the same results. It naturally uses scientific notation whenever the length is beyond the first of the 2 integers.