Hy Folks. Thanks in advance.
i wants to print only year from given data. please don’t send reference i’ve used all didn’t worked at all. i hope you will me give the correct code. PFA (Excel).Once again thanks
only year.xlsx (12.0 KB)
It would be great, if you could show us what you have tried so far? if any error received, show that too.
you may try this
Thanks for your fast reply.
i created a veriable named “year”. i used
but it is only giving me the current year.
and also i’ve used
CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(new DateTime(2019, 12, 02) , currentCulture.DateTimeFormat.CalendarWeekRule, currentCulture.DateTimeFormat.FirstDayOfweek)
which is giving me the correct year but i don’t wants to mentioned the date.
without mentioning the date and it should take the data from excel file. and it should print only year.
change data type of “Year” to string
Please use the below method.
string strIn = row("Columnname").tostring
dateTime dt = DateTime.ParseExact(strIn, "dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)
string strOut = dt.ToString("yyyy")
@THIRU_NANI - I didn’t use Preserve Format while reading, just to see how the value is read from the excel. Then in the next line I have used Datetime.parseexact to extract the year…
Hi @THIRU_NANI ,
Try below code and let me know if you face any issue.
Refer Output sheet for output
test.xaml (6.8 KB)
Test.xlsx (10.2 KB)
Thank you so much guys for your fast response. I’ll check the codes tomorrow.
Please can you also tell me how to find out the week number from the same date.
It would be helpful.
Thanks a lot guys @sai_krishna_somisetty @prasath17 @pravin_calvin @ermanoj3101
Thanks and regards
Here you go…
CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(datetime.ParseExact(CurrentRow(0).ToString,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture), CalendarWeekRule.FirstDay,DayOfWeek.Monday).ToString
You can change calendarweekRule based on your requirement…
Hi @THIRU_NANI ,
If you don’t want unique years and only want to extract years then remove highlighted code from shared code and then run the bot.
Hi @sai_krishna_somisetty it is working
To get the week number, using this code
Assign this to a interger variable, as it gives integer result.
Hi @sai_krishna_somisetty ,
Thank you so much for your help
@THIRU_NANI - In the Import Tab…you have just to add “System.Globalization” that’s all.
This is code is just a shorter version.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.