anmita
February 6, 2023, 2:21pm
1
Hello Everyone,
How can we get the week no using this format
startDate = New DateTime(2023,01,29)
targetDate = New DateTime(2023,02,05)
((CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7-1)).ToString
So it returns 1 currently
How can we get it as 01
So that for all Week no between 1 to 9 it should prefix 0
ppr
(Peter)
February 6, 2023, 2:24pm
2
Filling up with 0 we would do for strings like:
anmita
February 6, 2023, 2:28pm
3
Hi @ppr this approach will add for all 0
How can we define the condition that only till week 9 its prefixed not for all of them
ppr
(Peter)
February 6, 2023, 2:29pm
4
it will fill up when needed
Gokul001
(Gokul Balaji)
February 6, 2023, 2:41pm
5
Hi @anmita
How about this expression
If(((CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7)+1).ToString.Count=1,"0"+CStr((CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7)+1),CStr((CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7)+1))
Regards
Gokul
Hello @anmita
Just try by adding (“D2”) in your expression
((CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7-1)).ToString("D2")
anmita
February 6, 2023, 3:31pm
8
Hi @Gokul_Jayakumar
Thanks for approach
Can you let me know if for 11 will it be shown as 011 because that would be incorrect
system
(system)
Closed
February 13, 2023, 6:35am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.