Need help to edit code LINQ?

Hey @fairymemay

Is the Approve date a date time variable and which is format is it currently ?

Thanks
#nK

@Nithinkrishna yes approveDate as Datetime

variable approveDate = DateTime.ParseExact(ApproveDateStr,“dd MMM”,System.Globalization.CultureInfo.InvariantCulture)

1 Like

Hey @fairymemay

What’s the format of it - Thai date or normal date ?

Thanks
#nK

@Nithinkrishna I read ApproveDate after - and If today month3 —> I assume year now but if today month1 —> I assume previous year.

image

But use column Issue Date same.
image

1 Like

Hey @fairymemay

Try this if it helps…

nmnithinkrishna_BuddishtCalendarDateComparison.zip (2.4 KB)

Thanks
#nK

@Nithinkrishna Sorry I use column วันที่รับเล่ม
Not Approve Date

image
ref.xlsx (8.9 KB)

1 Like

Hey @fairymemay

Kindly use this in your query condition,

DateTime.ParseExact(x("Issue Date").ToString, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) <= Date.ParseExact(x("วันที่รับเล่ม (<=)").ToString.Trim,"dd/M/yyyy",System.Globalization.CultureInfo.InvariantCulture)

The above condition will only do the date column comparison as requested for other columns you can add along with this.

Thanks
#nK

@Nithinkrishna

If I don’t use column วันที่รับเล่ม
Because I read value already in variable DateReceived as string = 04/05/2022 (dd/mm/yyyy)

1 Like

Sorry, unable to understand. Kindly explain.

Thanks
#nK

@Nithinkrishna From your suggest
Date.ParseExact(x(“วันที่รับเล่ม (<=)”).ToString.Trim,“dd/M/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

If I want read data in Date.ParseExact(x(“วันที่รับเล่ม (<=)”).ToString

Because I have variable Example 18/1/2022 as string

How to edit your code?

1 Like

Yes the above code converts string to date by itself.

That’s is what you need I believe ?

@Nithinkrishna How​ to​ use​ variable​DateReceived in​ code?

1 Like

Okay @fairymemay Got it.

You can just replace this x(“วันที่รับเล่ม (<=)”).ToString.Trim with your variable

Thanks
#nK

@Nithinkrishna I use follow your suggest but error as below.

image

1 Like

Hey @fairymemay

Kindly show the date value please which you are passing through that variable ?

Thanks
#nK

@Nithinkrishna String as below.

image

Hey @fairymemay

It’s due to the format conflict.

Replace the format from the above as MM/dd/yyyy.

Hope this helps

Thanks
#nK

@Nithinkrishna If I want change from column Issue Date to column วันรับเล่ม as below.

image

If file excel column วันรับเล่ม as format text

How to edit code from below?

DateTime.ParseExact(x(“Issue Date”).ToString, “yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture)

1 Like

Hey @fairymemay

Please find the updated below,

ateTime.ParseExact(x(“วันรับเล่ม”).ToString, “dd/MM/yyyy HH:mm”, System.Globalization.CultureInfo.InvariantCulture)

Thanks
#nK

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.