Monday, November 5, 2012

Basic date Regular Expressions



  1. "dd/mm/yyyy","(3[01]|[12][0-9]|0[1-9])/(0[1-9]|1[012])/[1-2][0-9][0-9][0-9]"
  2. "dd-mmm-yy","(3[01]|[12][0-9]|0[1-9])[-/][a-zA-Z][a-zA-Z][a-zA-Z][-/][1-2][0-9][0-9][0-9]"
  3. "MM/dd/yyyy","(0[1-9]|1[012])/(3[01]|[12][0-9]|0[1-9])/[1-2][0-9][0-9][0-9]"
  4. "yyyy-mm-dd","[1-2][0-9][0-9][0-9][-/](0[1-9]|1[012])[-/](3[01]|[12][0-9]|0[1-9])"  
  5. "yyyy/mm/dd","[1-2][0-9][0-9][0-9]/(0[1-9]|1[012])/(3[01]|[12][0-9]|0[1-9])" 
I cheated on MMM , I know
 

Anomolies of Spreadsheetgear with dates

1)Spreadsheetgear converts "-" into "/"
                so if you have a spreadsheet with a date thus


2011-01-03


                  Spreadsheetgear will convert it to
                                 
                                      2011/01/03

2) Spreadsheetgear describes DD/MM/YYYY,MM/DD/YYYY and YYYY/MM/DD with "\/", but not
YYYY-MM-DD

therefore

 
excel format:DD/MM/YYYY sh/g format:dd\/mm\/yyyy - 01/01/2011
excel format:MM/DD/YYYY sh/g format:mm\/dd\/yyyy - 02/01/2011
excel format:YYYY-MM-DD sh/g format:yyyy/mm/dd - 2011/01/03
excel format:DD-MMM-YYYY sh/g format:dd/mmm/yyyy - 04/Jan/2011
excel format:YYYY/MM/DD sh/g format:yyyy\/mm\/dd - 2011/01/05

3) a date coming from a CSV with a value of 04-Jan-2011 will be converted to d-mmm-yy, 4-Jan-11

4) an excel file that has dates formatted as "Date" will be read by excel with the default culture. Therefore, if you open the file with your own custom culture - this will be the format of the "Date" cells.




Looping through controls with Jquery

I had a situation where components were being created by a custom control inheriting a repeater - the repeater had a dropdown and was being propogated multiple times but always ended with "blah" in the name - the issue was setting all the dropdowns under certain conditions. this is how I did it:


 onClick ='$("[id$=blah]").each( function() { if (this.options[1].value== "whatever"  && this.selectedIndex ==0 ){ this.options[1].selected = true }   ;}      );'

Thursday, October 25, 2012

TryParseExact formats

what does this return?

DateTime.TryParseExact(stringArray[columnNum], "yyyy/MM/dd", dateTimeFormatterProvider, DateTimeStyles.None, out date)  when the value is 1999/02/23?


false

why? because its not a standard format?

the answer : use CultureInfo.InvariantCulture

Monday, October 22, 2012

Warnings in SSIS

apparently fail a package in run time, as opposed to , for e.g. , management studio which just shows a warning

Wednesday, October 17, 2012

DeletedRowInaccessibleException & linq

I was receiving this even though in the where clause I excluded deleted rows

i had to do this




//to avoid DeletedRowInaccessibleException errors AcceptChanges
            blah.AcceptChanges();

submitdisabledcontrols



submitdisabledcontrols="true" in the form tag will not help for when the server disables the control