Android Question Find the first and the last day of the year

BitsAndBytes

Active Member
Licensed User
I want to create a report between the first day of current year and the last date of the current year and store those on 2 long variables as ticks. How i will create those 2 dates dynamical?

Thank you
 

Mahares

Expert
Licensed User
Longtime User
B4X:
Log(DateTime.DateParse("1/1/" & DateTime.GetYear(DateTime.Now))) 
Log(DateTime.DateParse("12/31/" & DateTime.GetYear(DateTime.Now)))
'Second line can be 31/12 depending on your date format

EDIT: I should mention that you can also use DateUtils library and use this code to return the same result:
B4X:
Log($"${DateUtils.SetDate(DateTime.GetYear(DateTime.Now),1,1)}"$ )  
Log($"${DateUtils.SetDate(DateTime.GetYear(DateTime.Now),12,31)}"$ )
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…