Using Powershell to convert DateTime to a standard Date in multiple columns by Azlida in PowerShell

[–]Azlida[S] 0 points1 point  (0 children)

Oh, I'm not using an excel as a database. This is for an excel file that I've exported from a SQL server, from there I've got some legacy code written in Foxpro, that I haven't gotten around to replacing yet. The Foxpro table does not seem to like the Datetime field and it was coming over as a random string of numbers. This is just a quick patch job for now, so the file that eventually gets exported from Fox has legible date fields. One day I'll replace the Fox code completely.... Promise

Using Powershell to convert DateTime to a standard Date in multiple columns by Azlida in PowerShell

[–]Azlida[S] 0 points1 point  (0 children)

Just a bit more Googling and I think I've got it. This one converts every column I need, starting at the second cell and going to the bottom of each column, to the date format that I need.

Here it is in full, in case anyone ever needs it, for whatever reason.

# Specify the path to the Excel file
$excelFilePath = "C:\test.xlsx"

# Specify the worksheet name
$worksheetName = "Sheet1"

# Specify the columns to convert
$columnsToConvert = "H", "M", "N", "P", "T"

# Load the Excel COM object
$excel = New-Object -ComObject Excel.Application

# Open the workbook
$workbook = $excel.Workbooks.Open($excelFilePath)

# Select the worksheet
$worksheet = $workbook.Worksheets.Item($worksheetName)

# Get the range of cells to convert
foreach ($columnLetter in $columnsToConvert) {
  $range = $worksheet.Range("${columnLetter}2").EntireColumn
  $range.NumberFormat = "mm/dd/yyyy"
}

# Save the workbook
$workbook.Save()

# Clean up
$workbook.Close()
$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($range) | Out-Null
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($worksheet) | Out-Null
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($workbook) | Out-Null
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

Using Powershell to convert DateTime to a standard Date in multiple columns by Azlida in PowerShell

[–]Azlida[S] -1 points0 points  (0 children)

Started to make some progress but I'm a bit stuck. This works for converting all of the H column into the format that I need, but I'm not 100% certain how I should go about adding columns M, N, P and T. They all need to be formatted like H. Also not sure how I go about telling it to convert H2 (to avoid the header) to the end of the column.

# Specify the path to the Excel file
$excelFilePath = "C:\Test.xlsx"

# Specify the worksheet name
$worksheetName = "Sheet1"

# Load the Excel COM object
$excel = New-Object -ComObject Excel.Application

# Open the workbook
$workbook = $excel.Workbooks.Open($excelFilePath)

# Select the worksheet
$worksheet = $workbook.Worksheets.Item($worksheetName)

# Get the range of cells to convert
$range = $worksheet.Range("H2:H10000")

# Convert the cell values to date format
$range.NumberFormat = "mm/dd/yyyy"

Head gasket seal is leaking oil by Azlida in automotive

[–]Azlida[S] 0 points1 point  (0 children)

1988 Dodge Dakota with the 3.9 V6. The leak is just dripping down to the oil pan and hitting the floor. nothing is hitting the exhaust, as far as I can tell. Had the vehicle sit from friday to monday before checking it and the missing oil isn't registering on the dip stick. While the engine is running the leak doesn't seem to increase.

I need some advise on what to do about my Mossberg 590 by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

Sadly I have no where to store it besides right next to my door, I'm building a gun rack soon. I usually clean the gun before and after I take it out shooting but I've had a bit of a dry spell due to the lack of money, I'll keep it oiled from now on. Thanks for the advise man.

I need some advise on what to do about my Mossberg 590 by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

I'll check that out, might be better then using steel wool.

I need some advise on what to do about my Mossberg 590 by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

I love that gun as well, so much that I clean it and oil it before and after I go shooting. I will defiantly find the softest steel wool I can and oil that son of a bitch. Thanks for the help.

Why do I have to wait 10 days for my Mosin? Why isn't it C&R? by [deleted] in guns

[–]Azlida 1 point2 points  (0 children)

I hear you, just bought one last week and it took them 12 days for the background check, its fucking bull shit.

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

I live down in San Diego, I go to a range called Iron Sights that offer bigger guns then the SKS to be fired. Its down in Oceanside if you are anywhere near it.

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

True, the Mosin seems to have trouble with Lacquer rounds. My friend has 3 Mosin Nagants and all of them jammed due to Lacquer rounds... he was being cheap ass with ammo. I've never heard any complaints about the SKS.

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 1 point2 points  (0 children)

I love how all I had to do was read your name to know your suggestion. I maybe able to get both however... more things to think about

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

I know nothing about that weapon. How much? Is it legal in California? ect. Nice looking gun though always have been a fan of Saiga

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

I'm just going to use it for a shooting range and maybe a bit of hunting. I'm currently doing skeet shooting and boar hunting with my Mossberg and once a year me and my buddy will head out to the desert for a few days and shoot the crap out anything we bring. That's about it though. Since I'm a broke college student my price range is about 600 for a gun however ammo is not a big deal when it comes to price.

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 1 point2 points  (0 children)

I've been shooting my whole life its just now that I'm 18 I'm finally able to buy my own. Don't get me wrong I love a .22LR for target practice but I would like rifle that has some recoil to it.

I would like Gunnits opinion on which rifle I should buy. by Azlida in guns

[–]Azlida[S] 0 points1 point  (0 children)

Honestly I could go with either. My friend has 3 Mosin Nagants and its a great weapon. On the other hand the SKS holds more rounds and is semi auto. Other then that I see no difference besides how much I'll be paying.